From 20c296cac728c8c7113d79a1c438ffd331f2d87e Mon Sep 17 00:00:00 2001 From: Chad Burggraf Date: Tue, 20 Dec 2016 07:17:24 -0700 Subject: [PATCH] Add redux-batched-actions typings. (#13054) --- redux-batched-actions/index.d.ts | 23 +++++++++++++++++++ redux-batched-actions/package.json | 5 ++++ .../redux-batched-actions-tests.ts | 14 +++++++++++ redux-batched-actions/tsconfig.json | 19 +++++++++++++++ redux-batched-actions/tslint.json | 3 +++ 5 files changed, 64 insertions(+) create mode 100644 redux-batched-actions/index.d.ts create mode 100644 redux-batched-actions/package.json create mode 100644 redux-batched-actions/redux-batched-actions-tests.ts create mode 100644 redux-batched-actions/tsconfig.json create mode 100644 redux-batched-actions/tslint.json diff --git a/redux-batched-actions/index.d.ts b/redux-batched-actions/index.d.ts new file mode 100644 index 0000000000..3d3970a0f5 --- /dev/null +++ b/redux-batched-actions/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for redux-batched-actions 0.1 +// Project: https://github.com/tshelburne/redux-batched-actions +// 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; + + /** + * Creates a higher-order reducer that enables batching + * actions for the given reducer. + */ + export function enableBatching(reducer: Reducer): Reducer; +} diff --git a/redux-batched-actions/package.json b/redux-batched-actions/package.json new file mode 100644 index 0000000000..6cfd8dc05c --- /dev/null +++ b/redux-batched-actions/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "redux": "^3.6.0" + } +} \ No newline at end of file diff --git a/redux-batched-actions/redux-batched-actions-tests.ts b/redux-batched-actions/redux-batched-actions-tests.ts new file mode 100644 index 0000000000..51e6966010 --- /dev/null +++ b/redux-batched-actions/redux-batched-actions-tests.ts @@ -0,0 +1,14 @@ +import { Reducer, createStore } from 'redux'; +import { Action, createAction } from 'redux-actions'; +import { enableBatching, batchActions } from 'redux-batched-actions'; + +const doThing = createAction('DO_THING'); +const doOther = createAction('DO_OTHER'); + +const reducer = (state: any = {}, action: Action): any => { + return state; +}; + +const store = createStore(enableBatching(reducer), {}); + +store.dispatch(batchActions([doThing(), doOther()])); diff --git a/redux-batched-actions/tsconfig.json b/redux-batched-actions/tsconfig.json new file mode 100644 index 0000000000..26205680f8 --- /dev/null +++ b/redux-batched-actions/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "redux-batched-actions-tests.ts" + ] +} \ No newline at end of file diff --git a/redux-batched-actions/tslint.json b/redux-batched-actions/tslint.json new file mode 100644 index 0000000000..192203ab54 --- /dev/null +++ b/redux-batched-actions/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file