From d2bf4fe0fa72655253180645e73dca48129b9027 Mon Sep 17 00:00:00 2001 From: Derek Sifford Date: Wed, 10 Jul 2019 18:50:51 -0400 Subject: [PATCH] [@wordpress/redux-routine] add new definitions (#36688) --- types/wordpress__redux-routine/index.d.ts | 20 +++++++++++++++++++ types/wordpress__redux-routine/package.json | 6 ++++++ types/wordpress__redux-routine/tsconfig.json | 19 ++++++++++++++++++ types/wordpress__redux-routine/tslint.json | 1 + .../wordpress__redux-routine-tests.ts | 11 ++++++++++ 5 files changed, 57 insertions(+) create mode 100644 types/wordpress__redux-routine/index.d.ts create mode 100644 types/wordpress__redux-routine/package.json create mode 100644 types/wordpress__redux-routine/tsconfig.json create mode 100644 types/wordpress__redux-routine/tslint.json create mode 100644 types/wordpress__redux-routine/wordpress__redux-routine-tests.ts diff --git a/types/wordpress__redux-routine/index.d.ts b/types/wordpress__redux-routine/index.d.ts new file mode 100644 index 0000000000..15d5e391fc --- /dev/null +++ b/types/wordpress__redux-routine/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for @wordpress/redux-routine 3.4 +// Project: https://github.com/WordPress/gutenberg/tree/master/packages/redux-routine/README.md +// Definitions by: Derek Sifford +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.5 + +import { AnyAction, Middleware } from 'redux'; + +/** + * Creates a Redux middleware, given an object of controls where each key is an action type for + * which to act upon, the value a function which returns either a promise which is to resolve when + * evaluation of the action should continue, or a value. The value or resolved promise value is + * assigned on the return value of the yield assignment. If the control handler returns undefined, + * the execution is not continued. + * + * @param controls - Object of control handlers. + */ +declare function createMiddleware(controls?: Record any>): Middleware; + +export default createMiddleware; diff --git a/types/wordpress__redux-routine/package.json b/types/wordpress__redux-routine/package.json new file mode 100644 index 0000000000..7cc600c266 --- /dev/null +++ b/types/wordpress__redux-routine/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "redux": "^4.0.1" + } +} diff --git a/types/wordpress__redux-routine/tsconfig.json b/types/wordpress__redux-routine/tsconfig.json new file mode 100644 index 0000000000..d8384bf48e --- /dev/null +++ b/types/wordpress__redux-routine/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@wordpress/redux-routine": ["wordpress__redux-routine"] + } + }, + "files": ["index.d.ts", "wordpress__redux-routine-tests.ts"] +} diff --git a/types/wordpress__redux-routine/tslint.json b/types/wordpress__redux-routine/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/wordpress__redux-routine/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/wordpress__redux-routine/wordpress__redux-routine-tests.ts b/types/wordpress__redux-routine/wordpress__redux-routine-tests.ts new file mode 100644 index 0000000000..44d33fbfce --- /dev/null +++ b/types/wordpress__redux-routine/wordpress__redux-routine-tests.ts @@ -0,0 +1,11 @@ +import { createStore, applyMiddleware } from 'redux'; +import createMiddleware from '@wordpress/redux-routine'; + +const middleware = createMiddleware({ + FOO: action => action.foo, + BAR(action) { + return action.bar; + }, +}); + +const store = createStore(state => state, applyMiddleware(middleware));