diff --git a/types/wepy-redux/index.d.ts b/types/wepy-redux/index.d.ts index 8e16e57b27..be516d18eb 100644 --- a/types/wepy-redux/index.d.ts +++ b/types/wepy-redux/index.d.ts @@ -2,9 +2,10 @@ // Project: https://github.com/Tencent/wepy/tree/1.7.x/packages/wepy-redux // Definitions by: Jiayu Liu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import wepy from "wepy"; +import { Store } from "redux"; export interface MapStateToProps { [propName: string]: ((state: any) => any) | string; @@ -18,4 +19,6 @@ export function connect( mapDispatchToProps: MapDispatchToProps ): ((original: T) => T); -export function setStore(store: any): void; +export function setStore(store: Store): void; + +export function getStore(): Store; diff --git a/types/wepy-redux/package.json b/types/wepy-redux/package.json new file mode 100644 index 0000000000..7f5b19d45b --- /dev/null +++ b/types/wepy-redux/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "redux": "^4.0.0" + } +} diff --git a/types/wepy-redux/wepy-redux-tests.ts b/types/wepy-redux/wepy-redux-tests.ts index 65274613ab..8444c7cc2e 100644 --- a/types/wepy-redux/wepy-redux-tests.ts +++ b/types/wepy-redux/wepy-redux-tests.ts @@ -1,5 +1,17 @@ import wepy from "wepy"; -import { connect } from "wepy-redux"; +import { createStore } from "redux"; +import { connect, getStore, setStore } from "wepy-redux"; + +const store = createStore( + (counter: number | undefined, action: { type: string; payload: number }) => + counter || 0 + action.payload, + 0 +); + +setStore(store); + +const s = getStore(); +s.dispatch({ type: "a" }); interface State { counter: {