add wepy-redux

This commit is contained in:
Jiayu Liu
2018-06-26 22:08:57 +08:00
parent 4663cef676
commit b8dd6a05f4
5 changed files with 83 additions and 5 deletions
+21
View File
@@ -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 <https://github.com/Jimexist>
// 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: wepy.component) => wepy.component;
export function setStore(store: any): void;
+17
View File
@@ -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"]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+29
View File
@@ -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 = {
// ...
};
// ...
onLoad() {}
}
+13 -5
View File
@@ -13,12 +13,20 @@ import util from "./util";
import base from "./base";
import { WxEnhances } from "./wx_enhanced";
export as namespace wepy;
export type event = typeof event;
export type component = typeof component;
export type app = typeof app;
export type page = typeof page;
export type mixin = typeof mixin;
interface DefaultExport extends WxEnhances {
event: typeof event;
app: typeof app;
component: typeof component;
page: typeof page;
mixin: typeof mixin;
event: wepy.event;
app: wepy.app;
component: wepy.component;
page: wepy.page;
mixin: wepy.mixin;
$createApp: typeof base.$createApp;
$createPage: typeof base.$createPage;
$isEmpty: typeof util.$isEmpty;