diff --git a/notNeededPackages.json b/notNeededPackages.json index 36ad9cc418..7424ea4d17 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -2124,12 +2124,6 @@ "sourceRepoURL": "https://github.com/redux-saga/redux-saga", "asOfVersion": "0.10.5" }, - { - "libraryName": "redux-saga-routines", - "typingsPackageName": "redux-saga-routines", - "sourceRepoURL": "https://github.com/afitiskin/redux-saga-routines#readme", - "asOfVersion": "2.1.0" - }, { "libraryName": "Redux Thunk", "typingsPackageName": "redux-thunk", diff --git a/types/redux-saga-routines/index.d.ts b/types/redux-saga-routines/index.d.ts new file mode 100644 index 0000000000..9efceeedae --- /dev/null +++ b/types/redux-saga-routines/index.d.ts @@ -0,0 +1,160 @@ +// Type definitions for redux-saga-routines 3.0 +// Project: https://github.com/afitiskin/redux-saga-routines +// Definitions by: Alexey Pelykh +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +import { Dispatch } from 'redux'; +import { + Action, + ActionMeta, + createAction, + ActionFunctions, + ActionWithMetaFunctions, + ActionFunction0, + ActionFunction1, + ActionFunction2, + ActionFunction3, + ActionFunction4, + ActionFunctionAny, +} from 'redux-actions'; +import { FormSubmitHandler } from 'redux-form'; + +export function routinePromiseWatcherSaga(): Generator; + +export type ActionCreator = ActionFunctions | ActionWithMetaFunctions; + +export type Routine< + TTriggerActionCreator = ActionCreator +> = TTriggerActionCreator & { + TRIGGER: string; + REQUEST: string; + SUCCESS: string; + FAILURE: string; + FULFILL: string; +} & { + trigger: TTriggerActionCreator; + request: ActionCreator; + success: ActionCreator; + failure: ActionCreator; + fulfill: ActionCreator; +}; + +export interface ReduxFormPayload { + values: TFormData; + props: TProps; +} + +export function bindRoutineToReduxForm< + TFormData = {}, + TProps = {}, +>( + routine: Routine< + ActionFunction1, + Action>> + > | Routine< + ActionFunction1, + ActionMeta, any>> + >, + noSuccessPayload?: boolean, +): FormSubmitHandler; + +export type PromiseCreator< + TPayload = {}, +> = (payload: TPayload, dispatch: Dispatch) => PromiseLike; + +export function promisifyRoutine( + routine: Routine, +): PromiseCreator; + +export type BoundPromiseCreator< + TPayload = {}, +> = (payload: TPayload) => PromiseLike; + +export function bindPromiseCreators( + promiseCreator: PromiseCreator, + dispatch: Dispatch, +): BoundPromiseCreator; + +export function bindPromiseCreators( + promiseCreators: { [key: string]: PromiseCreator }, + dispatch: Dispatch, +): { [key: string]: BoundPromiseCreator }; + +export function bindPromiseCreators( + promiseCreators: { [key: number]: PromiseCreator }, + dispatch: Dispatch, +): { [key: number]: BoundPromiseCreator }; + +export const ROUTINE_PROMISE_ACTION: string; + +// TODO: support https://github.com/afitiskin/redux-saga-routines/commit/9eb5a240df25d771f9dfbd4cb90e898d111242ab + +export function createRoutine( + typePrefix: string, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: ActionFunction0, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: ActionFunction1, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: ActionFunction2, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: ActionFunction3, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: ActionFunction4, +): Routine>>; + +export function createRoutine( + typePrefix: string, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: null | undefined, + metaCreator: ActionFunctionAny, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: ActionFunctionAny, + metaCreator: ActionFunctionAny, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: ActionFunction1, + metaCreator: ActionFunction1, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: ActionFunction2, + metaCreator: ActionFunction2, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: ActionFunction3, + metaCreator: ActionFunction3, +): Routine>>; + +export function createRoutine( + typePrefix: string, + payloadCreator: ActionFunction4, + metaCreator: ActionFunction4, +): Routine>>; diff --git a/types/redux-saga-routines/package.json b/types/redux-saga-routines/package.json new file mode 100644 index 0000000000..998f8e9b38 --- /dev/null +++ b/types/redux-saga-routines/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "redux": "^3.6.0 || ^4.0.0" + } +} diff --git a/types/redux-saga-routines/redux-saga-routines-tests.ts b/types/redux-saga-routines/redux-saga-routines-tests.ts new file mode 100644 index 0000000000..eb4f54bbf4 --- /dev/null +++ b/types/redux-saga-routines/redux-saga-routines-tests.ts @@ -0,0 +1,10 @@ +import { + routinePromiseWatcherSaga, + Routine, + ReduxFormPayload, + bindRoutineToReduxForm, + promisifyRoutine, + bindPromiseCreators, + ROUTINE_PROMISE_ACTION, + createRoutine, +} from 'redux-saga-routines'; diff --git a/types/redux-saga-routines/tsconfig.json b/types/redux-saga-routines/tsconfig.json new file mode 100644 index 0000000000..1b75000df5 --- /dev/null +++ b/types/redux-saga-routines/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "redux-saga-routines-tests.ts" + ] +} diff --git a/types/redux-saga-routines/tslint.json b/types/redux-saga-routines/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/redux-saga-routines/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }