Skip to content

Commit 9c3ea28

Browse files
Kohei Asaiunional
authored andcommitted
Bugfix: Remove dependency to a namespace JSX of React (#11)
* Add test * Disable lint in build Don't want to make too many changes. * Re-enable allowSynDefault for examples * Remove dependency to a namespace `JSX` of React
1 parent 68c455f commit 9c3ea28

File tree

6 files changed

+39
-30
lines changed

6 files changed

+39
-30
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ node_js:
99
- "stable"
1010

1111
script:
12-
- npm run lint+build+test
12+
- npm run verify

examples/active-links.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="../typings/main.d.ts" />
1+
/// <reference path="../typings/index.d.ts" />
22
/// <reference path="../react-router.d.ts" />
33

44
import React from 'react';
@@ -120,4 +120,4 @@ render((
120120
</Route>
121121
</Route>
122122
</Router>
123-
), document.getElementById('example'));
123+
), document.getElementById('example'));

examples/auth.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
export = {
2-
login(email?:any, pass?:any, cb?:any) {
3-
cb = arguments[arguments.length - 1]
2+
login(email?: any, pass?: any, cb?: any) {
3+
cb = arguments[arguments.length - 1];
44
if (localStorage['token']) {
5-
if (cb) cb(true);
6-
this.onChange(true)
7-
return
5+
if (cb) {
6+
cb(true);
7+
}
8+
this.onChange(true);
9+
return;
810
}
9-
pretendRequest(email, pass, (res:any) => {
11+
pretendRequest(email, pass, (res: any) => {
1012
if (res.authenticated) {
11-
localStorage['token'] = res.token
12-
if (cb) cb(true)
13-
this.onChange(true)
13+
localStorage['token'] = res.token;
14+
if (cb) {
15+
cb(true);
16+
}
17+
this.onChange(true);
1418
} else {
15-
if (cb) cb(false)
16-
this.onChange(false)
19+
if (cb) {
20+
cb(false);
21+
}
22+
this.onChange(false);
1723
}
1824
})
1925
},
@@ -22,28 +28,30 @@ export = {
2228
return localStorage['token']
2329
},
2430

25-
logout(cb?:any) {
31+
logout(cb?: any) {
2632
delete localStorage['token']
27-
if (cb) cb()
28-
this.onChange(false)
33+
if (cb) {
34+
cb();
35+
}
36+
this.onChange(false);
2937
},
3038

3139
loggedIn() {
3240
return !!localStorage['token']
3341
},
3442

35-
onChange() {}
36-
}
43+
onChange() { }
44+
};
3745

38-
function pretendRequest(email:any, pass:any, cb:any) {
46+
function pretendRequest(email: any, pass: any, cb: any) {
3947
setTimeout(() => {
4048
if (email === '[email protected]' && pass === 'password1') {
4149
cb({
4250
authenticated: true,
4351
token: Math.random().toString(36).substring(7)
44-
})
52+
});
4553
} else {
46-
cb({ authenticated: false })
54+
cb({ authenticated: false });
4755
}
48-
}, 0)
49-
}
56+
}, 0);
57+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"source-test": "echo running source tests... && echo no source test",
88
"test": "echo running server tests... && cd test && ts-node ../node_modules/blue-tape/bin/blue-tape \"**/*.ts\" | tap-spec",
99
"watch": "onchange -w \"**/*.ts\" -i -e \"out/**\" -- npm -s run build+test",
10-
"publish": "npm -s run lint+build+test && echo please publish to typings/registry",
10+
"publish": "npm -s run verify && echo please publish to typings/registry",
1111
"all-tests": "npm test",
1212
"build+test": "npm run build && npm run all-tests",
13-
"lint+build+test": "npm run lint && npm run build+test",
13+
"verify": "npm run build+test",
1414
"prepublish": "typings install"
1515
},
1616
"devDependencies": {

react-router.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ declare namespace ReactRouter {
5858
* @param {Components<IProps, any>} component
5959
* @param {IProps} props
6060
*/
61-
createElement?<IProps>(component: ReactComponent<IProps>, props: IProps): JSX.Element;
61+
createElement?<IProps>(component: ReactComponent<IProps>, props: IProps): React.ReactElement<IProps>;
6262

6363
/**
6464
* A function used to convert an object from <Link>s or calls to transitionTo to a URL query string.
@@ -91,7 +91,7 @@ declare namespace ReactRouter {
9191
* This is primarily for integrating with other libraries that need to participate in rendering before the route components are rendered. It defaults to render={(props) => <RouterContext {...props} />}.
9292
* Ensure that you render a <RouterContext> at the end of the line, passing all the props passed to render.
9393
*/
94-
render?<IProps>(props: IProps): JSX.Element;
94+
render?<IProps>(props: IProps): React.ReactElement<IProps>;
9595
}
9696

9797

@@ -785,7 +785,7 @@ declare namespace ReactRouter {
785785
/**
786786
* Add router object to props of pure component
787787
*/
788-
export function withRouter<T>(fun: (props: T & { router: IRouter }) => JSX.Element): (props: T) => JSX.Element;
788+
export function withRouter<T>(fun: (props: T & { router: IRouter }) => React.ReactElement<T>): (props: T) => React.ReactElement<T>;
789789

790790
/**
791791
* Add router object to props of component
@@ -795,7 +795,7 @@ declare namespace ReactRouter {
795795
/**
796796
* Apply Router middleware (for using in <Router render={applyRouterMiddleware(...)} ... />)
797797
*/
798-
export function applyRouterMiddleware<T extends Function>(middleware: T): <IProps>(props: IProps) => JSX.Element;
798+
export function applyRouterMiddleware<T extends Function>(middleware: T): <IProps>(props: IProps) => React.ReactElement<IProps>;
799799
}
800800

801801
export = ReactRouter;

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
34
"target": "es6",
45
"module": "commonjs",
56
"jsx": "react",

0 commit comments

Comments
 (0)