From 4ec1572a3dcabff56279973922aed2ebb4981a80 Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Thu, 12 Oct 2017 07:47:26 +0900 Subject: [PATCH] Add definitions for redux-saga-routines (#20481) --- types/redux-saga-routines/index.d.ts | 35 +++++++++++++++++++ types/redux-saga-routines/package.json | 7 ++++ .../redux-saga-routines-tests.tsx | 28 +++++++++++++++ types/redux-saga-routines/tsconfig.json | 24 +++++++++++++ types/redux-saga-routines/tslint.json | 1 + 5 files changed, 95 insertions(+) create mode 100644 types/redux-saga-routines/index.d.ts create mode 100644 types/redux-saga-routines/package.json create mode 100644 types/redux-saga-routines/redux-saga-routines-tests.tsx create mode 100644 types/redux-saga-routines/tsconfig.json create mode 100644 types/redux-saga-routines/tslint.json diff --git a/types/redux-saga-routines/index.d.ts b/types/redux-saga-routines/index.d.ts new file mode 100644 index 0000000000..d01e5edddf --- /dev/null +++ b/types/redux-saga-routines/index.d.ts @@ -0,0 +1,35 @@ +// Type definitions for redux-saga-routines 2.0 +// Project: https://github.com/afitiskin/redux-saga-routines#readme +// Definitions by: Karol Janyst +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import { Action } from "redux"; +import { FormSubmitHandler } from "redux-form"; + +export const ROUTINE_PROMISE_ACTION: string; + +export interface RoutineAction extends Action { + payload: T; +} + +export type RoutineActionCreator = (payload: T) => RoutineAction; + +export interface ReduxRoutine { + TRIGGER: string; + REQUEST: string; + SUCCESS: string; + FAILURE: string; + FULFILL: string; + trigger: RoutineActionCreator; + request: RoutineActionCreator; + success: RoutineActionCreator; + failure: RoutineActionCreator; + fulfill: RoutineActionCreator; +} + +export function createRoutine(prefix: string): ReduxRoutine; + +export function routinePromiseWatcherSaga(): Iterator; + +export function bindRoutineToReduxForm(routine: ReduxRoutine): FormSubmitHandler; diff --git a/types/redux-saga-routines/package.json b/types/redux-saga-routines/package.json new file mode 100644 index 0000000000..ce10629c07 --- /dev/null +++ b/types/redux-saga-routines/package.json @@ -0,0 +1,7 @@ +{ + "private": true, + "dependencies": { + "redux": "^3.7.2", + "redux-saga": "^0.15.6" + } +} diff --git a/types/redux-saga-routines/redux-saga-routines-tests.tsx b/types/redux-saga-routines/redux-saga-routines-tests.tsx new file mode 100644 index 0000000000..4cf2a62c4a --- /dev/null +++ b/types/redux-saga-routines/redux-saga-routines-tests.tsx @@ -0,0 +1,28 @@ +import * as React from "react"; +import { reduxForm } from "redux-form"; +import createSagaMiddleware from "redux-saga"; +import { + bindRoutineToReduxForm, + createRoutine, + routinePromiseWatcherSaga, + ROUTINE_PROMISE_ACTION +} from "redux-saga-routines"; + +const sagaMiddleware = createSagaMiddleware(); + +sagaMiddleware.run(routinePromiseWatcherSaga); + +const submitFormRoutine = createRoutine("SUBMIT_MY_FORM"); +const submitFormHandler = bindRoutineToReduxForm(submitFormRoutine); + +const Test = reduxForm({ + form : "test" +})( + ({ handleSubmit }) => { + return ( +
+ +
+ ); + } +); diff --git a/types/redux-saga-routines/tsconfig.json b/types/redux-saga-routines/tsconfig.json new file mode 100644 index 0000000000..32f2937910 --- /dev/null +++ b/types/redux-saga-routines/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "redux-saga-routines-tests.tsx" + ] +} 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" }