-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test files for typescript definition files
- Loading branch information
Showing
17 changed files
with
3,605 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ dist | |
coverage | ||
.nyc_output | ||
npm-debug.log | ||
test/typescript/*.map | ||
test/typescript/*.jsx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import fetch from '../../fetch'; | ||
|
||
fetch('', { | ||
headers: {}, | ||
method: 'post', | ||
redirect: 'follow', | ||
}).then(res => { | ||
res.type; | ||
res.url; | ||
res.body; | ||
res.json(); | ||
res.headers; | ||
res.statusText; | ||
}); | ||
|
||
fetch(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import dva, { connect } from '../../index'; | ||
import { routerRedux } from '../../router'; | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
|
||
/** | ||
* dva() | ||
*/ | ||
const app = dva({ | ||
onError(e) { | ||
e.message; | ||
e.stack; | ||
}, | ||
onAction: [], | ||
onStateChange: () => {}, | ||
onReducer: () => {}, | ||
onEffect: () => {}, | ||
onHmr: () => {}, | ||
extraReducers: { | ||
form() {}, | ||
}, | ||
}); | ||
// no option | ||
dva(); | ||
|
||
/** | ||
* app.use() | ||
*/ | ||
app.use({ | ||
onError() {} | ||
}) | ||
|
||
/** | ||
* app.model() | ||
*/ | ||
app.model({ | ||
namespace: 'count', | ||
state: 0, | ||
subscriptions: { | ||
setup({ dispatch, history }, done) {}, | ||
}, | ||
effects: { | ||
*addRemote({ type }, { call, put, select, take, cancel }) { | ||
yield put({ | ||
type: 'a', | ||
}); | ||
yield put(routerRedux.push('/')); | ||
}, | ||
// Support effect with type | ||
minusRemote: [ | ||
function*() {}, | ||
{ type: 'takeLatest' } | ||
], | ||
}, | ||
reducers: { | ||
add(state) { return state + 1 }, | ||
minus(state) { return state - 1 }, | ||
}, | ||
}); | ||
// Support reducers with reducer enhancer | ||
app.model({ | ||
namespace: 'x', | ||
reducers: [{}, () => {}], | ||
}); | ||
|
||
/** | ||
* connect() | ||
*/ | ||
function App() { | ||
return <div>App</div>; | ||
} | ||
connect()(App); | ||
const AppContainer = connect((state) => ({ count: state.count }))(App); | ||
|
||
/** | ||
* app.router() | ||
*/ | ||
app.router(() => <div />); | ||
app.router(({ history }) => <div />); | ||
|
||
// dynamic route | ||
app.router(({ history, app }) => { | ||
app.model({ | ||
namespace: 'x' | ||
}); | ||
return {}; | ||
}); | ||
|
||
/** | ||
* app.start() | ||
*/ | ||
app.start('#root'); | ||
app.start(document.getElementById('#root')); | ||
|
||
// with no arguments | ||
const jsx = app.start(); | ||
ReactDOM.render(jsx, document.getElementById('#root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import dva, { connect } from '../../mobile'; | ||
|
||
const app = dva(); | ||
app.use({}); | ||
app.model({ namespace: 'count' }); | ||
app.router(() => ({})); | ||
app.start(); | ||
|
||
connect()(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { | ||
Router, | ||
Route, | ||
Link, | ||
routerRedux, | ||
} from '../../router'; | ||
|
||
function App() { | ||
return ( | ||
<div><Link to="/404">1</Link></div> | ||
); | ||
} | ||
|
||
function getRouter() { | ||
return ( | ||
<Router> | ||
<Route path="/" component={App} /> | ||
</Router> | ||
); | ||
} | ||
|
||
routerRedux.push('/'); | ||
routerRedux.go('/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"moduleResolution": "node", | ||
"jsx": "preserve", | ||
"module": "commonjs", | ||
"sourceMap": true | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Generated by typings | ||
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/b9642fb8ac07f7164dc643ddd1fa99b58ae9be8b/react/react-dom.d.ts | ||
declare namespace __React { | ||
namespace __DOM { | ||
function findDOMNode<E extends Element>(instance: ReactInstance): E; | ||
function findDOMNode(instance: ReactInstance): Element; | ||
|
||
function render<P extends DOMAttributes, T extends Element>( | ||
element: DOMElement<P, T>, | ||
container: Element, | ||
callback?: (element: T) => any): T; | ||
function render<P>( | ||
element: SFCElement<P>, | ||
container: Element, | ||
callback?: () => any): void; | ||
function render<P, T extends Component<P, ComponentState>>( | ||
element: CElement<P, T>, | ||
container: Element, | ||
callback?: (component: T) => any): T; | ||
function render<P>( | ||
element: ReactElement<P>, | ||
container: Element, | ||
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void; | ||
|
||
function unmountComponentAtNode(container: Element): boolean; | ||
|
||
var version: string; | ||
|
||
function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void; | ||
function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void; | ||
function unstable_batchedUpdates(callback: () => any): void; | ||
|
||
function unstable_renderSubtreeIntoContainer<P extends DOMAttributes, T extends Element>( | ||
parentComponent: Component<any, any>, | ||
element: DOMElement<P, T>, | ||
container: Element, | ||
callback?: (element: T) => any): T; | ||
function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>( | ||
parentComponent: Component<any, any>, | ||
element: CElement<P, T>, | ||
container: Element, | ||
callback?: (component: T) => any): T; | ||
function render<P>( | ||
parentComponent: Component<any, any>, | ||
element: SFCElement<P>, | ||
container: Element, | ||
callback?: () => any): void; | ||
function unstable_renderSubtreeIntoContainer<P>( | ||
parentComponent: Component<any, any>, | ||
element: ReactElement<P>, | ||
container: Element, | ||
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void; | ||
} | ||
|
||
namespace __DOMServer { | ||
function renderToString(element: ReactElement<any>): string; | ||
function renderToStaticMarkup(element: ReactElement<any>): string; | ||
var version: string; | ||
} | ||
} | ||
|
||
declare module "react-dom" { | ||
import DOM = __React.__DOM; | ||
export = DOM; | ||
} | ||
|
||
declare module "react-dom/server" { | ||
import DOMServer = __React.__DOMServer; | ||
export = DOMServer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"resolution": "main", | ||
"tree": { | ||
"src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/b9642fb8ac07f7164dc643ddd1fa99b58ae9be8b/react/react-dom.d.ts", | ||
"raw": "registry:dt/react-dom#0.14.0+20160412154040", | ||
"typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/b9642fb8ac07f7164dc643ddd1fa99b58ae9be8b/react/react-dom.d.ts" | ||
} | ||
} |
Oops, something went wrong.