diff --git a/argon2/index.d.ts b/argon2/index.d.ts index f4e4c41d1f..1cbf1a5156 100644 --- a/argon2/index.d.ts +++ b/argon2/index.d.ts @@ -5,40 +5,35 @@ /// -declare namespace argon2 { +export var defaults: { + timeCost: number; + memoryCost: number; + parallelism: number; + argon2d: boolean; +}; - export var defaults: { - timeCost: number; - memoryCost: number; - parallelism: number; - argon2d: boolean; +export var limits: { + memoryCost: { + min: number; + max: number; }; - - export var limits: { - memoryCost: { - min: number; - max: number; - }; - timeCost: { - min: number; - max: number; - }; - parallelism: { - min: number; - max: number; - }; + timeCost: { + min: number; + max: number; }; + parallelism: { + min: number; + max: number; + }; +}; - export function hash(plain: string, salt: Buffer, options?: { - timeCost?: number; - memoryCost?: number; - parallelism?: number; - argon2d?: boolean; - }): Promise; +export function hash(plain: string, salt: Buffer, options?: { + timeCost?: number; + memoryCost?: number; + parallelism?: number; + argon2d?: boolean; +}): Promise; - export function verify(hash: string, plain: string): Promise; +export function verify(hash: string, plain: string): Promise; - export function generateSalt(length?: number): Promise; -} - -export = argon2; +export function generateSalt(length?: number): Promise; diff --git a/halogen/index.d.ts b/halogen/index.d.ts index 5a6448899c..72d57ace51 100644 --- a/halogen/index.d.ts +++ b/halogen/index.d.ts @@ -5,84 +5,78 @@ import * as react from "react"; -export = Halogen; - -declare namespace Halogen { - - type VerticalAlign = "baseline" | "length" | "sub" | "super" | "top" | "text-top" | "middle" | "bottom" | "text-bottom" | "initial" | "inherit"; - - interface HalogenCommonProps { - loading?: boolean; - color?: string; - id?: string; - className?: string; - verticalAlign?: VerticalAlign; - } - - interface SizeLoaderProps extends HalogenCommonProps { - size?: string; - } - - interface MarginLoaderProps extends HalogenCommonProps { - margin?: T; - size?: T; - } - - interface RadiusLoaderProps extends MarginLoaderProps { - height?: string; - width?: string; - radius?: string; - } - - /** - * React components - */ - type PulseLoader = react.Component, {}>; - export const PulseLoader: react.ComponentClass>; - - type RotateLoader = react.Component, {}>; - export const RotateLoader: react.ComponentClass>; - - type BeatLoader = react.Component, {}>; - export const BeatLoader: react.ComponentClass>; - - type RiseLoader = react.Component, {}>; - export const RiseLoader: react.ComponentClass>; - - type SyncLoader = react.Component, {}>; - export const SyncLoader: react.ComponentClass>; - - type GridLoader = react.Component, {}>; - export const GridLoader: react.ComponentClass>; - - type ClipLoader = react.Component; - export const ClipLoader: react.ComponentClass; - - type SquareLoader = react.Component; - export const SquareLoader: react.ComponentClass; - - type DotLoader = react.Component; - export const DotLoader: react.ComponentClass; - - type PacmanLoader = react.Component, {}>; - export const PacmanLoader: react.ComponentClass>; - - type MoonLoader = react.Component; - export const MoonLoader: react.ComponentClass; - - type RingLoader = react.Component; - export const RingLoader: react.ComponentClass; - - type BounceLoader = react.Component; - export const BounceLoader: react.ComponentClass; - - type SkewLoader = react.Component; - export const SkewLoader: react.ComponentClass; - - type FadeLoader = react.Component; - export const FadeLoader: react.ComponentClass; - - type ScaleLoader = react.Component; - export const ScaleLoader: react.ComponentClass; +type VerticalAlign = "baseline" | "length" | "sub" | "super" | "top" | "text-top" | "middle" | "bottom" | "text-bottom" | "initial" | "inherit"; +interface HalogenCommonProps { + loading?: boolean; + color?: string; + id?: string; + className?: string; + verticalAlign?: VerticalAlign; } + +interface SizeLoaderProps extends HalogenCommonProps { + size?: string; +} + +interface MarginLoaderProps extends HalogenCommonProps { + margin?: T; + size?: T; +} + +interface RadiusLoaderProps extends MarginLoaderProps { + height?: string; + width?: string; + radius?: string; +} + +/** + * React components + */ +type PulseLoader = react.Component, {}>; +export const PulseLoader: react.ComponentClass>; + +type RotateLoader = react.Component, {}>; +export const RotateLoader: react.ComponentClass>; + +type BeatLoader = react.Component, {}>; +export const BeatLoader: react.ComponentClass>; + +type RiseLoader = react.Component, {}>; +export const RiseLoader: react.ComponentClass>; + +type SyncLoader = react.Component, {}>; +export const SyncLoader: react.ComponentClass>; + +type GridLoader = react.Component, {}>; +export const GridLoader: react.ComponentClass>; + +type ClipLoader = react.Component; +export const ClipLoader: react.ComponentClass; + +type SquareLoader = react.Component; +export const SquareLoader: react.ComponentClass; + +type DotLoader = react.Component; +export const DotLoader: react.ComponentClass; + +type PacmanLoader = react.Component, {}>; +export const PacmanLoader: react.ComponentClass>; + +type MoonLoader = react.Component; +export const MoonLoader: react.ComponentClass; + +type RingLoader = react.Component; +export const RingLoader: react.ComponentClass; + +type BounceLoader = react.Component; +export const BounceLoader: react.ComponentClass; + +type SkewLoader = react.Component; +export const SkewLoader: react.ComponentClass; + +type FadeLoader = react.Component; +export const FadeLoader: react.ComponentClass; + +type ScaleLoader = react.Component; +export const ScaleLoader: react.ComponentClass; diff --git a/navigation-react/index.d.ts b/navigation-react/index.d.ts index edd9e746f2..131ce29735 100644 --- a/navigation-react/index.d.ts +++ b/navigation-react/index.d.ts @@ -5,89 +5,85 @@ import { StateNavigator } from 'navigation'; import { Component, HTMLProps } from 'react'; -export = NavigationReact; - -declare namespace NavigationReact { +/** + * Defines the Link Props contract + */ +interface LinkProps extends HTMLProps { /** - * Defines the Link Props contract + * Indicates whether Links listen for navigate events */ - interface LinkProps extends HTMLProps { - /** - * Indicates whether Links listen for navigate events - */ - lazy?: boolean; - /** - * Determines the effect on browser history - */ - historyAction?: 'add' | 'replace' | 'none'; - /** - * Handles Link click events - */ - navigating?: (e: MouseEvent, domId: string, link: string) => boolean; - /** - * The State Navigator - */ - stateNavigator?: StateNavigator; - } - + lazy?: boolean; /** - * Defines the Refresh Link Props contract + * Determines the effect on browser history */ - interface RefreshLinkProps extends LinkProps { - /** - * The NavigationData to pass - */ - navigationData?: any; - /** - * Indicates whether to include all the current NavigationData - */ - includeCurrentData?: boolean; - /** - * The data to add from the current NavigationData - */ - currentDataKeys?: string; - /** - * The Css Class to display when the Link is active - */ - activeCssClass?: string; - /** - * Indicates whether the Link is disabled when active - */ - disableActive?: boolean; - } - + historyAction?: 'add' | 'replace' | 'none'; /** - * Hyperlink Component the navigates to the current State + * Handles Link click events */ - class RefreshLink extends Component { } - + navigating?: (e: MouseEvent, domId: string, link: string) => boolean; /** - * Defines the Navigation Link Props contract + * The State Navigator */ - interface NavigationLinkProps extends RefreshLinkProps { - /** - * The key of the State to navigate to - */ - stateKey: string; - } - - /** - * Hyperlink Component the navigates to a State - */ - class NavigationLink extends Component { } - - /** - * Defines the Navigation Back Link Props contract - */ - interface NavigationBackLinkProps extends RefreshLinkProps { - /** - * Starting at 1, The number of Crumb steps to go back - */ - distance: number; - } - - /** - * Hyperlink Component the navigates back along the crumb trail - */ - class NavigationBackLink extends Component { } + stateNavigator?: StateNavigator; } + +/** + * Defines the Refresh Link Props contract + */ +interface RefreshLinkProps extends LinkProps { + /** + * The NavigationData to pass + */ + navigationData?: any; + /** + * Indicates whether to include all the current NavigationData + */ + includeCurrentData?: boolean; + /** + * The data to add from the current NavigationData + */ + currentDataKeys?: string; + /** + * The Css Class to display when the Link is active + */ + activeCssClass?: string; + /** + * Indicates whether the Link is disabled when active + */ + disableActive?: boolean; +} + +/** + * Hyperlink Component the navigates to the current State + */ +export class RefreshLink extends Component { } + +/** + * Defines the Navigation Link Props contract + */ +interface NavigationLinkProps extends RefreshLinkProps { + /** + * The key of the State to navigate to + */ + stateKey: string; +} + +/** + * Hyperlink Component the navigates to a State + */ +export class NavigationLink extends Component { } + +/** + * Defines the Navigation Back Link Props contract + */ +interface NavigationBackLinkProps extends RefreshLinkProps { + /** + * Starting at 1, The number of Crumb steps to go back + */ + distance: number; +} + +/** + * Hyperlink Component the navigates back along the crumb trail + */ +export class NavigationBackLink extends Component { } diff --git a/react-native-fs/index.d.ts b/react-native-fs/index.d.ts index a700005032..934d684a74 100644 --- a/react-native-fs/index.d.ts +++ b/react-native-fs/index.d.ts @@ -5,186 +5,182 @@ /// -declare namespace RNFS { - interface ReadDirItem { - // The name of the item - name: string; - // The absolute path to the item - path: string; - // Size in bytes - size: string; - // Is the file just a file? - isFile(): boolean; - // Is the file a directory? - isDirectory(): boolean; - } - - interface StatResult { - // The name of the item - name: string; - // The absolute path to the item - path: string; - // Size in bytes - size: string; - // UNIX file mode - mode: number; - // Is the file just a file? - isFile(): boolean; - // Is the file a directory? - isDirectory(): boolean; - } - - interface Headers { - [index: string]: string; - } - type Fields = Headers; - - interface MkdirOptions { - // iOS only - NSURLIsExcludedFromBackupKey?: boolean; - } - - interface DownloadResult { - // The download job ID, required if one wishes to cancel the download. See `stopDownload`. - jobId: number; - // The HTTP status code - statusCode: number; - // The number of bytes written to the file - bytesWritten: number; - } - - type DownloadCallbackBegin = (res: DownloadBeginCallbackResult) => void; - type DownloadCallbackProgress = (res: DownloadProgressCallbackResult) => void; - - interface DownloadFileOptions { - // URL to download file from - fromUrl: string; - // Local filesystem path to save the file to - toFile: string; - // An object of headers to be passed to the server - headers?: Headers; - background?: boolean; - progressDivider?: number; - begin?: DownloadCallbackBegin; - progress?: DownloadCallbackProgress; - } - - interface DownloadProgressCallbackResult { - // The download job ID, required if one wishes to cancel the download. See `stopDownload`. - jobId: number; - // The total size in bytes of the download resource - contentLength: number; - // The number of bytes written to the file so far - bytesWritten: number; - } - - interface DownloadBeginCallbackResult { - // The download job ID, required if one wishes to cancel the download. See `stopDownload`. - jobId: number; - // The HTTP status code - statusCode: number; - // The total size in bytes of the download resource - contentLength: number; - // The HTTP response headers from the server - headers: Headers; - } - - type UploadCallbackBegin = (res: UploadBeginCallbackResult) => void; - type UploadCallbackProgress = (res: UploadProgressCallbackResult) => void; - - interface UploadFileOptions { - // URL to upload file to - toUrl: string; - // An array of objects with the file information to be uploaded. - files: UploadFileItem[]; - // An object of headers to be passed to the server - headers?: Headers; - // An object of fields to be passed to the server - fields?: Fields; - // Default is 'POST', supports 'POST' and 'PUT' - method?: string; - begin?: UploadCallbackBegin; - progress?: UploadCallbackProgress; - } - - interface UploadResult { - // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. - jobId: number; - // The HTTP status code - statusCode: number; - // The HTTP response headers from the server - headers: Headers; - // The HTTP response body - body: string; - } - - interface UploadFileItem { - // Name of the file, if not defined then filename is used - name: string; - // Name of file - filename: string; - // Path to file - filepath: string; - // The mimetype of the file to be uploaded, if not defined it will get mimetype from `filepath` extension - filetype: string; - } - - interface UploadBeginCallbackResult { - // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. - jobId: number; - } - - interface UploadProgressCallbackResult { - // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. - jobId: number; - // The total number of bytes that will be sent to the server - totalBytesExpectedToSend: number; - // The number of bytes sent to the server - totalBytesSent: number; - } - - interface FSInfoResult { - // The total amount of storage space on the device (in bytes). - totalSpace: number; - // The amount of available storage space on the device (in bytes). - freeSpace: number; - } - - interface JobReturnValue { - jobId: number; - promise: Promise; - } - - // The absolute path to the main bundle directory - export const MainBundlePath: string; - // The absolute path to the caches directory - export const CachesDirectoryPath: string; - // The absolute path to the document directory - export const DocumentDirectoryPath: string; - // The absolute path to the temporary directory (iOS only) - export const TemporaryDirectoryPath: string; - // The absolute path to the external files, shared directory (android only) - export const ExternalDirectoryPath: string; - // The absolute path to the external storage, shared directory (android only) - export const ExternalStorageDirectoryPath: string; - - export function readDir(path: string): Promise; - export function readdir(path: string): Promise; - export function stat(filepath: string): Promise; - export function readFile(filepath: string, encoding?: string): Promise; - export function unlink(filepath: string): Promise; - export function writeFile(filepath: string, contents: string, encoding?: string): Promise; - export function appendFile(filepath: string, contents: string, encoding?: string): Promise; - export function moveFile(filepath: string, destPath: string): Promise; - export function copyFile(filepath: string, destPath: string): Promise; - export function exists(filepath: string): Promise; - export function hash(filepath: string, algorithm: string): Promise; - export function mkdir(filepath: string, options?: MkdirOptions): Promise; - export function downloadFile(options: DownloadFileOptions): JobReturnValue; - export function stopDownload(jobId: number): Promise; - export function uploadFiles(options: UploadFileOptions): JobReturnValue; - export function stopUpload(jobId: number): Promise; - export function getFSInfo(): Promise; +interface ReadDirItem { + // The name of the item + name: string; + // The absolute path to the item + path: string; + // Size in bytes + size: string; + // Is the file just a file? + isFile(): boolean; + // Is the file a directory? + isDirectory(): boolean; } -export = RNFS; \ No newline at end of file +interface StatResult { + // The name of the item + name: string; + // The absolute path to the item + path: string; + // Size in bytes + size: string; + // UNIX file mode + mode: number; + // Is the file just a file? + isFile(): boolean; + // Is the file a directory? + isDirectory(): boolean; +} + +interface Headers { + [index: string]: string; +} +type Fields = Headers; + +interface MkdirOptions { + // iOS only + NSURLIsExcludedFromBackupKey?: boolean; +} + +interface DownloadResult { + // The download job ID, required if one wishes to cancel the download. See `stopDownload`. + jobId: number; + // The HTTP status code + statusCode: number; + // The number of bytes written to the file + bytesWritten: number; +} + +type DownloadCallbackBegin = (res: DownloadBeginCallbackResult) => void; +type DownloadCallbackProgress = (res: DownloadProgressCallbackResult) => void; + +interface DownloadFileOptions { + // URL to download file from + fromUrl: string; + // Local filesystem path to save the file to + toFile: string; + // An object of headers to be passed to the server + headers?: Headers; + background?: boolean; + progressDivider?: number; + begin?: DownloadCallbackBegin; + progress?: DownloadCallbackProgress; +} + +interface DownloadProgressCallbackResult { + // The download job ID, required if one wishes to cancel the download. See `stopDownload`. + jobId: number; + // The total size in bytes of the download resource + contentLength: number; + // The number of bytes written to the file so far + bytesWritten: number; +} + +interface DownloadBeginCallbackResult { + // The download job ID, required if one wishes to cancel the download. See `stopDownload`. + jobId: number; + // The HTTP status code + statusCode: number; + // The total size in bytes of the download resource + contentLength: number; + // The HTTP response headers from the server + headers: Headers; +} + +type UploadCallbackBegin = (res: UploadBeginCallbackResult) => void; +type UploadCallbackProgress = (res: UploadProgressCallbackResult) => void; + +interface UploadFileOptions { + // URL to upload file to + toUrl: string; + // An array of objects with the file information to be uploaded. + files: UploadFileItem[]; + // An object of headers to be passed to the server + headers?: Headers; + // An object of fields to be passed to the server + fields?: Fields; + // Default is 'POST', supports 'POST' and 'PUT' + method?: string; + begin?: UploadCallbackBegin; + progress?: UploadCallbackProgress; +} + +interface UploadResult { + // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. + jobId: number; + // The HTTP status code + statusCode: number; + // The HTTP response headers from the server + headers: Headers; + // The HTTP response body + body: string; +} + +interface UploadFileItem { + // Name of the file, if not defined then filename is used + name: string; + // Name of file + filename: string; + // Path to file + filepath: string; + // The mimetype of the file to be uploaded, if not defined it will get mimetype from `filepath` extension + filetype: string; +} + +interface UploadBeginCallbackResult { + // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. + jobId: number; +} + +interface UploadProgressCallbackResult { + // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`. + jobId: number; + // The total number of bytes that will be sent to the server + totalBytesExpectedToSend: number; + // The number of bytes sent to the server + totalBytesSent: number; +} + +interface FSInfoResult { + // The total amount of storage space on the device (in bytes). + totalSpace: number; + // The amount of available storage space on the device (in bytes). + freeSpace: number; +} + +interface JobReturnValue { + jobId: number; + promise: Promise; +} + +// The absolute path to the main bundle directory +export const MainBundlePath: string; +// The absolute path to the caches directory +export const CachesDirectoryPath: string; +// The absolute path to the document directory +export const DocumentDirectoryPath: string; +// The absolute path to the temporary directory (iOS only) +export const TemporaryDirectoryPath: string; +// The absolute path to the external files, shared directory (android only) +export const ExternalDirectoryPath: string; +// The absolute path to the external storage, shared directory (android only) +export const ExternalStorageDirectoryPath: string; + +export function readDir(path: string): Promise; +export function readdir(path: string): Promise; +export function stat(filepath: string): Promise; +export function readFile(filepath: string, encoding?: string): Promise; +export function unlink(filepath: string): Promise; +export function writeFile(filepath: string, contents: string, encoding?: string): Promise; +export function appendFile(filepath: string, contents: string, encoding?: string): Promise; +export function moveFile(filepath: string, destPath: string): Promise; +export function copyFile(filepath: string, destPath: string): Promise; +export function exists(filepath: string): Promise; +export function hash(filepath: string, algorithm: string): Promise; +export function mkdir(filepath: string, options?: MkdirOptions): Promise; +export function downloadFile(options: DownloadFileOptions): JobReturnValue; +export function stopDownload(jobId: number): Promise; +export function uploadFiles(options: UploadFileOptions): JobReturnValue; +export function stopUpload(jobId: number): Promise; +export function getFSInfo(): Promise; diff --git a/react-test-renderer/index.d.ts b/react-test-renderer/index.d.ts index 59b48f99da..e3c27a057a 100644 --- a/react-test-renderer/index.d.ts +++ b/react-test-renderer/index.d.ts @@ -4,21 +4,18 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { ReactElement } from "react"; -declare namespace ReactTestRenderer { - export interface Renderer { - toJSON(): ReactTestRendererJSON; - } - export interface ReactTestRendererJSON { - type: string; - props: { [propName: string]: string }; - children: null | Array; - $$typeof?: any; - } - export interface TestRendererOptions { - createNodeMock: (element: ReactElement) => any; - } - // https://github.com/facebook/react/blob/master/src/renderers/testing/ReactTestMount.js#L155 - export function create(nextElement: ReactElement, options?: TestRendererOptions): Renderer; -} -export = ReactTestRenderer; +interface Renderer { + toJSON(): ReactTestRendererJSON; +} +interface ReactTestRendererJSON { + type: string; + props: { [propName: string]: string }; + children: null | Array; + $$typeof?: any; +} +interface TestRendererOptions { + createNodeMock: (element: ReactElement) => any; +} +// https://github.com/facebook/react/blob/master/src/renderers/testing/ReactTestMount.js#L155 +export function create(nextElement: ReactElement, options?: TestRendererOptions): Renderer; diff --git a/redux-actions/index.d.ts b/redux-actions/index.d.ts index e174683b88..a22a0b41cc 100644 --- a/redux-actions/index.d.ts +++ b/redux-actions/index.d.ts @@ -3,115 +3,112 @@ // Definitions by: Jack Hsu , Alex Gorbatchev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = ReduxActions; export as namespace ReduxActions; -declare namespace ReduxActions { - // FSA-compliant action. - // See: https://github.com/acdlite/flux-standard-action - interface BaseAction { - type: string; - } - - export interface Action extends BaseAction { - payload?: Payload; - error?: boolean; - } - - export interface ActionMeta extends Action { - meta: Meta; - } - - interface ReducerMap { - [actionType: string]: Reducer | ReducerNextThrow; - } - - interface ReducerMapMeta { - [actionType: string]: Reducer | ReducerNextThrow; - } - - interface ReducerNextThrow { - next?(state: State, action: Action): State; - throw?(state: State, action: Action): State; - } - - interface ReducerNextThrowMeta { - next?(state: State, action: ActionMeta): State; - throw?(state: State, action: ActionMeta): State; - } - - type ActionFunctions = ActionFunction0> | ActionFunction1> | ActionFunction2> | ActionFunction3> | ActionFunction4> | ActionFunctionAny>; - - type Reducer = (state: State, action: Action) => State; - - type ReducerMeta = (state: State, action: ActionMeta) => State; - - /** argument inferring borrowed from lodash definitions */ - type ActionFunction0 = () => R; - type ActionFunction1 = (t1: T1) => R; - type ActionFunction2 = (t1: T1, t2: T2) => R; - type ActionFunction3 = (t1: T1, t2: T2, t3: T3) => R; - type ActionFunction4 = (t1: T1, t2: T2, t3: T3, t4: T4) => R; - type ActionFunctionAny = (...args: any[]) => R; - - export function createAction( - actionType: string, - payloadCreator: ActionFunction0 - ): ActionFunction0>; - - export function createAction( - actionType: string, - payloadCreator: ActionFunction1 - ): ActionFunction1>; - - export function createAction( - actionType: string, - payloadCreator: ActionFunction2 - ): ActionFunction2>; - - export function createAction( - actionType: string, - payloadCreator: ActionFunction3 - ): ActionFunction3>; - - export function createAction( - actionType: string, - payloadCreator: ActionFunction4 - ): ActionFunction4>; - - export function createAction( - actionType: string - ): ActionFunctionAny>; - - export function createAction( - actionType: string, - payloadCreator: (...args: any[]) => Payload, - metaCreator: (...args: any[]) => Meta - ): (...args: any[]) => ActionMeta; - - export function handleAction( - actionType: string | ActionFunctions, - reducer: Reducer | ReducerNextThrow, - initialState: State - ): Reducer; - - export function handleAction( - actionType: { toString(): string }, - reducer: ReducerMeta | ReducerNextThrowMeta, - initialState: State - ): Reducer; - - export function handleActions( - reducerMap: ReducerMap, - initialState: StateAndPayload - ): Reducer; - - export function handleActions( - reducerMap: ReducerMap, - initialState: State - ): Reducer; - - export function combineActions( - ...actionTypes: Array> - ): Array>; +// FSA-compliant action. +// See: https://github.com/acdlite/flux-standard-action +interface BaseAction { + type: string; } + +interface Action extends BaseAction { + payload?: Payload; + error?: boolean; +} + +interface ActionMeta extends Action { + meta: Meta; +} + +interface ReducerMap { + [actionType: string]: Reducer | ReducerNextThrow; +} + +interface ReducerMapMeta { + [actionType: string]: Reducer | ReducerNextThrow; +} + +interface ReducerNextThrow { + next?(state: State, action: Action): State; + throw?(state: State, action: Action): State; +} + +interface ReducerNextThrowMeta { + next?(state: State, action: ActionMeta): State; + throw?(state: State, action: ActionMeta): State; +} + +type ActionFunctions = ActionFunction0> | ActionFunction1> | ActionFunction2> | ActionFunction3> | ActionFunction4> | ActionFunctionAny>; + +type Reducer = (state: State, action: Action) => State; + +type ReducerMeta = (state: State, action: ActionMeta) => State; + +/** argument inferring borrowed from lodash definitions */ +type ActionFunction0 = () => R; +type ActionFunction1 = (t1: T1) => R; +type ActionFunction2 = (t1: T1, t2: T2) => R; +type ActionFunction3 = (t1: T1, t2: T2, t3: T3) => R; +type ActionFunction4 = (t1: T1, t2: T2, t3: T3, t4: T4) => R; +type ActionFunctionAny = (...args: any[]) => R; + +export function createAction( + actionType: string, + payloadCreator: ActionFunction0 +): ActionFunction0>; + +export function createAction( + actionType: string, + payloadCreator: ActionFunction1 +): ActionFunction1>; + +export function createAction( + actionType: string, + payloadCreator: ActionFunction2 +): ActionFunction2>; + +export function createAction( + actionType: string, + payloadCreator: ActionFunction3 +): ActionFunction3>; + +export function createAction( + actionType: string, + payloadCreator: ActionFunction4 +): ActionFunction4>; + +export function createAction( + actionType: string +): ActionFunctionAny>; + +export function createAction( + actionType: string, + payloadCreator: (...args: any[]) => Payload, + metaCreator: (...args: any[]) => Meta +): (...args: any[]) => ActionMeta; + +export function handleAction( + actionType: string | ActionFunctions, + reducer: Reducer | ReducerNextThrow, + initialState: State +): Reducer; + +export function handleAction( + actionType: { toString(): string }, + reducer: ReducerMeta | ReducerNextThrowMeta, + initialState: State +): Reducer; + +export function handleActions( + reducerMap: ReducerMap, + initialState: StateAndPayload +): Reducer; + +export function handleActions( + reducerMap: ReducerMap, + initialState: State +): Reducer; + +export function combineActions( + ...actionTypes: Array> +): Array>; diff --git a/redux-actions/redux-actions-tests.ts b/redux-actions/redux-actions-tests.ts index 237d7fa04f..60923b9f10 100644 --- a/redux-actions/redux-actions-tests.ts +++ b/redux-actions/redux-actions-tests.ts @@ -1,4 +1,4 @@ -import ReduxActions = require("redux-actions"); +import * as ReduxActions from "redux-actions"; let state: number; const minimalAction: ReduxActions.BaseAction = { type: 'INCREMENT' }; diff --git a/redux-batched-actions/index.d.ts b/redux-batched-actions/index.d.ts index 3d3970a0f5..ad90e7d9fd 100644 --- a/redux-batched-actions/index.d.ts +++ b/redux-batched-actions/index.d.ts @@ -3,21 +3,18 @@ // Definitions by: Chad Burggraf // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = ReduxBatchedActions; -export as namespace ReduxBatchedActions; - import { Action, Reducer } from 'redux'; -declare namespace ReduxBatchedActions { - /** - * Batching action creator that creates a higher-order - * action from an array of actions. - */ - export function batchActions(actions: A[]): Action; +export as namespace ReduxBatchedActions; - /** - * Creates a higher-order reducer that enables batching - * actions for the given reducer. - */ - export function enableBatching(reducer: Reducer): Reducer; -} +/** + * Batching action creator that creates a higher-order + * action from an array of actions. + */ +export function batchActions(actions: A[]): Action; + +/** + * Creates a higher-order reducer that enables batching + * actions for the given reducer. + */ +export function enableBatching(reducer: Reducer): Reducer; diff --git a/xsd-schema-validator/index.d.ts b/xsd-schema-validator/index.d.ts index ae321e563b..c4fd02e8f5 100644 --- a/xsd-schema-validator/index.d.ts +++ b/xsd-schema-validator/index.d.ts @@ -5,12 +5,8 @@ /// -declare namespace XsdSchemaValidator { - export function validateXML(xml: string|NodeJS.ReadableStream|{file: string}, pathToXsd: string, callback: (err: Error, result: { - valid: boolean; - messages: string[]; - result: string; - }) => void): void; -} - -export = XsdSchemaValidator; \ No newline at end of file +export function validateXML(xml: string|NodeJS.ReadableStream|{file: string}, pathToXsd: string, callback: (err: Error, result: { + valid: boolean; + messages: string[]; + result: string; +}) => void): void;