dva provides its own types (#13379)

This commit is contained in:
Andy
2016-12-28 10:52:22 -05:00
committed by GitHub
parent 9159c2cf81
commit 690cf114d4
4 changed files with 6 additions and 124 deletions

View File

@@ -1,44 +0,0 @@
import dva from 'dva';
import { connect } from 'dva';
import { Router, Route } from 'dva/router';
import * as React from "react";
// 1. Initialize
const app = dva();
// 2. Model
app.model({
namespace: 'count',
state: 0,
reducers: {
add(count: number) {
return count + 1
},
minus(count: number) {
return count - 1
},
},
});
// 3. View
const App = connect(({ count }: any) => ({
count
}))(function ({ count, dispatch }: any) {
return (
<div>
<h2>{ count }</h2>
<button key="add" onClick={() => { dispatch({type: 'count/add'})}}>+</button>
<button key="minus" onClick={() => { dispatch({type: 'count/minus'})}}>-</button>
</div>
);
});
// 4. Router
app.router(({ history }: any) =>
<Router history={history}>
<Route path="/" component={App}/>
</Router>
);
// 5. Start
const countApp = app.start();

59
dva/index.d.ts vendored
View File

@@ -1,59 +0,0 @@
// Type definitions for dva v1.0.0
// Project: https://github.com/dvajs/dva
// Definitions by: nikogu <https://github.com/nikogu/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="react" />
declare module 'dva' {
/** connecting Container Components */
export function connect(maps:Object):Function;
export default function dva(opts?:Object):{
/** dva plugin */
use: (hooks:Object)=>void,
/** dva bootstrap */
start: (selector?:String|HTMLElement)=>void,
/** dva add model */
model: (model:Object)=>void,
/** dva setting router */
router: (router:Object)=>Object|JSX.Element,
};
}
/**
* https://github.com/reactjs/react-router
*/
declare module 'dva/router' {
interface RouterProps {
history?: Object
}
export class Router extends React.Component<RouterProps, {}> {
render():JSX.Element
}
interface RouteProps {
path?: string,
component?: React.ReactNode
}
export class Route extends React.Component<RouteProps, {}> {
render():JSX.Element
}
/**
* https://github.com/reactjs/react-router-redux
*/
export class routerRedux {}
}
/**
* https://github.com/fis-components/whatwg-fetch
*/
declare module 'dva/fetch' {
export default Function;
}

View File

@@ -1,21 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"dva-tests.tsx"
]
}

View File

@@ -226,6 +226,12 @@
"typingsPackageName": "Facebook's Immutable",
"sourceRepoURL": "https://github.com/facebook/immutable-js",
"asOfVersion": "3.8.7"
},
{
"libraryName": "dva",
"typingsPackageName": "dva",
"sourceRepoURL": "https://github.com/dvajs/dva",
"asOfVersion": "1.1.0"
}
]
}