mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
dva provides its own types (#13379)
This commit is contained in:
@@ -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
59
dva/index.d.ts
vendored
@@ -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;
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user