Update redux to 3.6.0 (#11302)

* Update redux to 3.6.0

In contrast to https://github.com/reactjs/redux/blob/v3.6.0/index.d.ts:
Because I didn't want to export Func0..3 I replaced them with their definition.

* Fixed missing line

* Correct errors

* Update test to redux v3.6.0

See 085eaec93d

* Adapt redux test

Corrected missing R.compose

* include Func0..3 types as in Redux' index.d.ts

* Update index.d.ts, include redux #1936

f8ec3ef1c3

* Update redux-tests.ts, include redux #1936

f8ec3ef1c3

* Update redux-devtools-tests.tsx
This commit is contained in:
Stephan 2016-10-05 22:47:26 +02:00 committed by Mohamed Hegazy
parent 87003eb27d
commit 54edf50ed5
3 changed files with 74 additions and 27 deletions

View File

@ -15,7 +15,7 @@ const DevTools = createDevTools(
<DevToolsMonitor />
)
const finalCreateStore = compose(
const finalCreateStore = compose<Redux.StoreEnhancerStoreCreator<{}>>(
DevTools.instrument(),
persistState('test-session')
)(createStore)

81
redux/index.d.ts vendored
View File

@ -1,4 +1,4 @@
// Type definitions for Redux v3.5.2
// Type definitions for Redux v3.6.0
// Project: https://github.com/reactjs/redux
// Definitions by: William Buchwalter <https://github.com/wbuchwalter/>, Vincent Prouillet <https://github.com/Keats/>, Kaur Kuut <https://github.com/xStrom>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@ -15,11 +15,11 @@ declare namespace Redux {
*
* Actions must have a `type` field that indicates the type of action being
* performed. Types can be defined as constants and imported from another
* module. Its better to use strings for `type` than Symbols because strings
* module. It's better to use strings for `type` than Symbols because strings
* are serializable.
*
* Other than `type`, the structure of an action object is really up to you.
* If youre interested, check out Flux Standard Action for recommendations on
* If you're interested, check out Flux Standard Action for recommendations on
* how actions should be constructed.
*/
interface Action {
@ -93,7 +93,7 @@ declare namespace Redux {
* `dispatch` function provided by the store instance without any middleware.
*
* The base dispatch function *always* synchronously sends an action to the
* stores reducer, along with the previous state returned by the store, to
* store's reducer, along with the previous state returned by the store, to
* calculate a new state. It expects actions to be plain objects ready to be
* consumed by the reducer.
*
@ -114,7 +114,7 @@ declare namespace Redux {
}
/**
* A store is an object that holds the applications state tree.
* A store is an object that holds the application's state tree.
* There should only be a single store in a Redux app, as the composition
* happens on the reducer level.
*
@ -220,7 +220,7 @@ declare namespace Redux {
* original store. There is an example in `compose` documentation
* demonstrating that.
*
* Most likely youll never write a store enhancer, but you may use the one
* Most likely you'll never write a store enhancer, but you may use the one
* provided by the developer tools. It is what makes time travel possible
* without the app being aware it is happening. Amusingly, the Redux
* middleware implementation is itself a store enhancer.
@ -308,7 +308,7 @@ declare namespace Redux {
* an action creator is a factory that creates an action.
*
* Calling an action creator only produces an action, but does not dispatch
* it. You need to call the stores `dispatch` function to actually cause the
* it. You need to call the store's `dispatch` function to actually cause the
* mutation. Sometimes we say *bound action creators* to mean functions that
* call an action creator and immediately dispatch its result to a specific
* store instance.
@ -366,6 +366,11 @@ declare namespace Redux {
/* compose */
type Func0<R> = () => R;
type Func1<T1, R> = (a1: T1) => R;
type Func2<T1, T2, R> = (a1: T1, a2: T2) => R;
type Func3<T1, T2, T3, R> = (a1: T1, a2: T2, a3: T3, ...args: any[]) => R;
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for the
@ -376,28 +381,56 @@ declare namespace Redux {
* to left. For example, `compose(f, g, h)` is identical to doing
* `(...args) => f(g(h(...args)))`.
*/
function compose(): <R>(a: R, ...args: any[]) => R;
function compose(): <R>(a: R) => R;
function compose<F extends Function>(f: F): F;
/* two functions */
function compose<A, R>(
f1: (b: A) => R,
f2: (...args: any[]) => A
): (...args: any[]) => R;
f1: (b: A) => R, f2: Func0<A>
): Func0<R>;
function compose<A, T1, R>(
f1: (b: A) => R, f2: Func1<T1, A>
): Func1<T1, R>;
function compose<A, T1, T2, R>(
f1: (b: A) => R, f2: Func2<T1, T2, A>
): Func2<T1, T2, R>;
function compose<A, T1, T2, T3, R>(
f1: (b: A) => R, f2: Func3<T1, T2, T3, A>
): Func3<T1, T2, T3, R>;
/* three functions */
function compose<A, B, R>(
f1: (b: B) => R,
f2: (a: A) => B,
f3: (...args: any[]) => A
): (...args: any[]) => R;
f1: (b: B) => R, f2: (a: A) => B, f3: Func0<A>
): Func0<R>;
function compose<A, B, T1, R>(
f1: (b: B) => R, f2: (a: A) => B, f3: Func1<T1, A>
): Func1<T1, R>;
function compose<A, B, T1, T2, R>(
f1: (b: B) => R, f2: (a: A) => B, f3: Func2<T1, T2, A>
): Func2<T1, T2, R>;
function compose<A, B, T1, T2, T3, R>(
f1: (b: B) => R, f2: (a: A) => B, f3: Func3<T1, T2, T3, A>
): Func3<T1, T2, T3, R>;
/* four functions */
function compose<A, B, C, R>(
f1: (b: C) => R,
f2: (a: B) => C,
f3: (a: A) => B,
f4: (...args: any[]) => A
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func0<A>
): Func0<R>;
function compose<A, B, C, T1, R>(
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func1<T1, A>
): Func1<T1, R>;
function compose<A, B, C, T1, T2, R>(
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func2<T1, T2, A>
): Func2<T1, T2, R>;
function compose<A, B, C, T1, T2, T3, R>(
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func3<T1, T2, T3, A>
): Func3<T1, T2, T3, R>;
/* rest */
function compose<R>(
f1: (b: any) => R, ...funcs: Function[]
): (...args: any[]) => R;
function compose<R>(
f1: (a: any) => R,
...funcs: Function[]
): (...args: any[]) => R;
}
function compose<R>(...funcs: Function[]): (...args: any[]) => R;
}

View File

@ -181,8 +181,22 @@ namespace EnumTypeAction {
const t5: number = R.compose(stringToNumber, numberToString, numberToNumber)(5);
const t6: string = R.compose(numberToString, stringToNumber, numberToString, numberToNumber)(5);
const t7: string = R.compose<string>(
const t7: string = R.compose(
numberToString, numberToNumber, stringToNumber, numberToString, stringToNumber)("fo");
const multiArgFn = (a: string, b: number, c: boolean): string => 'foo';
const t8: string = R.compose(multiArgFn)('bar', 42, true);
const t9: number = R.compose(stringToNumber, multiArgFn)('bar', 42, true);
const t10: string = R.compose(numberToString, stringToNumber,
multiArgFn)('bar', 42, true);
const t11: number = R.compose(stringToNumber, numberToString, stringToNumber,
multiArgFn)('bar', 42, true);
const funcs = [stringToNumber, numberToString, stringToNumber];
const t12 = R.compose(...funcs)('bar', 42, true);
}());
// dispatch.ts
@ -383,4 +397,4 @@ declare module "redux" {
}
store.replaceReducer(newReducer);
}());
}());