diff --git a/types/wepy-redux/index.d.ts b/types/wepy-redux/index.d.ts new file mode 100644 index 0000000000..8e16e57b27 --- /dev/null +++ b/types/wepy-redux/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for wepy-redux 1.7 +// 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 + +import wepy from "wepy"; + +export interface MapStateToProps { + [propName: string]: ((state: any) => any) | string; +} +export interface MapDispatchToProps { + [propName: string]: ((store: any, ...args: any[]) => void) | string; +} + +export function connect( + mapStateToProps: MapStateToProps, + mapDispatchToProps: MapDispatchToProps +): ((original: T) => T); + +export function setStore(store: any): void; diff --git a/types/wepy-redux/tsconfig.json b/types/wepy-redux/tsconfig.json new file mode 100644 index 0000000000..c7cc00bebf --- /dev/null +++ b/types/wepy-redux/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "experimentalDecorators": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "wepy-redux-tests.ts"] +} diff --git a/types/wepy-redux/tslint.json b/types/wepy-redux/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/wepy-redux/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/wepy-redux/wepy-redux-tests.ts b/types/wepy-redux/wepy-redux-tests.ts new file mode 100644 index 0000000000..65274613ab --- /dev/null +++ b/types/wepy-redux/wepy-redux-tests.ts @@ -0,0 +1,29 @@ +import wepy from "wepy"; +import { connect } from "wepy-redux"; + +interface State { + counter: { + num: number; + }; +} + +@connect( + { + num(state: State) { + return state.counter.num; + }, + inc: "inc" + }, + { + addNum: "INCREMENT", + asyncInc: () => {} + } +) +export default class Index extends wepy.page { + // methods + methods = { + // method values + }; + // on load + onLoad() {} +}