mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
added type definitions for multireducer (#35776)
* added type definitions for multireducer * added type definitions for multireducer fixed issues
This commit is contained in:
parent
369612c7c8
commit
8ce8f37634
20
types/multireducer/index.d.ts
vendored
Normal file
20
types/multireducer/index.d.ts
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Type definitions for multireducer 3.1
|
||||
// Project: https://github.com/erikras/multireducer
|
||||
// Definitions by: Anthony M. Lee <https://github.com/immigration9>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export interface MetaObject {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
export interface ActionObject {
|
||||
meta: MetaObject;
|
||||
[rest: string]: any;
|
||||
}
|
||||
|
||||
export function bindActionCreators(actions: any, dispatch: any, reducerKey: string): any;
|
||||
export function wrapDispatch(dispatch: any, reducerKey: string): any;
|
||||
export function wrapAction(action: any, reducerKey: string): ActionObject;
|
||||
|
||||
export default function multireducer(reducers: { [key: string]: any }, reducerKey?: string): (state: any, action: any) => any;
|
||||
26
types/multireducer/multireducer-tests.ts
Normal file
26
types/multireducer/multireducer-tests.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import multireducer from 'multireducer';
|
||||
import { deepEqual } from 'assert';
|
||||
|
||||
const initialState = { a: 1, b: 2, c: 3 };
|
||||
|
||||
const first = (state = initialState, action = {}) => {
|
||||
return { ...state, a: 10 };
|
||||
};
|
||||
|
||||
const second = (state = initialState, action = {}) => {
|
||||
return { ...state, b: 20 };
|
||||
};
|
||||
|
||||
const third = (state = initialState, action = {}) => {
|
||||
return { ...state, c: 30 };
|
||||
};
|
||||
|
||||
const reducers = multireducer({ first, second, third })(undefined, {});
|
||||
|
||||
const expectedResult = {
|
||||
first: { a: 10, b: 2, c: 3 },
|
||||
second: { a: 1, b: 20, c: 3 },
|
||||
third: { a: 1, b: 2, c: 30 }
|
||||
};
|
||||
|
||||
deepEqual(reducers, expectedResult);
|
||||
23
types/multireducer/tsconfig.json
Normal file
23
types/multireducer/tsconfig.json
Normal file
@ -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",
|
||||
"multireducer-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/multireducer/tslint.json
Normal file
1
types/multireducer/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user