[redux-immutable] Upgrade type definition to support Redux v4 + Immutable v4 (#29334)

* [redux-immutable] Move the current version to v3 subfolder

* [redux-immutable] Copied v3 over to root and update it to v4
This commit is contained in:
Kanitkorn Sujautra
2018-10-08 10:21:41 -07:00
committed by Andy
parent 82307b21d5
commit 29d283ca5c
8 changed files with 179 additions and 8 deletions
+7 -4
View File
@@ -1,12 +1,15 @@
// Type definitions for redux-immutable v3.0.33
// Type definitions for redux-immutable v4.0.0
// Project: https://github.com/gajus/redux-immutable
// Definitions by: Pedro Pereira <https://github.com/oizie>
// Sebastian Sebald <https://github.com/sebald>
// Gavin Gregory <https://github.com/gavingregory>
// Kanitkorn Sujautra <https://github.com/lukyth>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as Redux from 'redux';
import { ReducersMapObject, Reducer, Action } from 'redux';
import { Collection } from 'immutable';
export declare function combineReducers<S, T>(reducers: Redux.ReducersMapObject, getDefaultState?: () => Collection.Keyed<T, S>): Redux.Reducer<S>;
export declare function combineReducers<S>(reducers: Redux.ReducersMapObject, getDefaultState?: () => Collection.Indexed<S>): Redux.Reducer<S>;
export declare function combineReducers<S, A extends Action, T>(reducers: ReducersMapObject<S, A>, getDefaultState?: () => Collection.Keyed<T, S>): Reducer<S, A>;
export declare function combineReducers<S, A extends Action>(reducers: ReducersMapObject<S, A>, getDefaultState?: () => Collection.Indexed<S>): Reducer<S, A>;
export declare function combineReducers<S>(reducers: ReducersMapObject<S>, getDefaultState?: () => Collection.Indexed<S>): Reducer<S>;
+2 -2
View File
@@ -1,7 +1,7 @@
{
"private": true,
"dependencies": {
"redux": "^3.6.0",
"immutable": "^3.8.1"
"redux": "^4.0.0",
"immutable": "^4.0.0-rc.1"
}
}
+21 -2
View File
@@ -1,6 +1,7 @@
import { combineReducers } from 'redux-immutable';
import { Map, List } from 'immutable';
import { AnyAction } from 'redux';
// Dummy State interface
interface State { };
@@ -11,11 +12,29 @@ interface State { };
combineReducers({});
combineReducers<State>({});
/**
* Combine reducers support reducer with custom action
*/
combineReducers<State, { type: string; payload: number | string}>({
reducerNumber: (state: number, action: { type: string; payload: number }) => {
switch(action.type) {
case 'multiply': return state * action.payload
default: return state
}
},
reducerString: (state: string, action: { type: string; payload: string }) => {
switch(action.type) {
case 'concat': return state.concat(action.payload)
default: return state
}
},
});
/**
* Combine reducers should accepts a function (getDefaultState()) as a second parameter, that returns an immutable Collection.Keyed collection.
*/
combineReducers<State, string>({}, () => { return Map<string, State>(); });
combineReducers<State, number>({}, () => { return Map<number, State>(); });
combineReducers<State, AnyAction, string>({}, () => { return Map<string, State>(); });
combineReducers<State, AnyAction, number>({}, () => { return Map<number, State>(); });
/**
* Combine reducers should accepts a function (getDefaultState()) as a second parameter, that returns an immutable Collection.Indexed collection.
*/
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for redux-immutable v3.0.33
// Project: https://github.com/gajus/redux-immutable
// Definitions by: Pedro Pereira <https://github.com/oizie>
// Sebastian Sebald <https://github.com/sebald>
// Gavin Gregory <https://github.com/gavingregory>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as Redux from 'redux';
import { Collection } from 'immutable';
export declare function combineReducers<S, T>(reducers: Redux.ReducersMapObject, getDefaultState?: () => Collection.Keyed<T, S>): Redux.Reducer<S>;
export declare function combineReducers<S>(reducers: Redux.ReducersMapObject, getDefaultState?: () => Collection.Indexed<S>): Redux.Reducer<S>;
+7
View File
@@ -0,0 +1,7 @@
{
"private": true,
"dependencies": {
"redux": "^3.6.0",
"immutable": "^3.8.1"
}
}
@@ -0,0 +1,22 @@
import { combineReducers } from 'redux-immutable';
import { Map, List } from 'immutable';
// Dummy State interface
interface State { };
/**
* Combine reducers should work with only one argument (a reducers object).
*/
combineReducers({});
combineReducers<State>({});
/**
* Combine reducers should accepts a function (getDefaultState()) as a second parameter, that returns an immutable Collection.Keyed collection.
*/
combineReducers<State, string>({}, () => { return Map<string, State>(); });
combineReducers<State, number>({}, () => { return Map<number, State>(); });
/**
* Combine reducers should accepts a function (getDefaultState()) as a second parameter, that returns an immutable Collection.Indexed collection.
*/
combineReducers<State>({}, () => { return List<State>(); });
+29
View File
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": false,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"redux-immutable": [
"redux-immutable/v3"
]
}
},
"files": [
"index.d.ts",
"redux-immutable-tests.ts"
]
}
+79
View File
@@ -0,0 +1,79 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
}
}