Skip to content

Commit b72f4e2

Browse files
author
Andrew Ross
committed
Corrected minor problems with the examples.
2 parents 404e9a8 + 87a7fd7 commit b72f4e2

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

react-router.d.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ declare module ReactRouter {
6767
*
6868
* @param {Object} queryObject
6969
*/
70-
stringifyQuery?(queryObject: Object);
70+
stringifyQuery?(queryObject: Object): string;
7171

7272

7373
/**
@@ -82,12 +82,12 @@ declare module ReactRouter {
8282
*
8383
* @param {Error} error
8484
*/
85-
onError?(error: Error);
85+
onError?(error: Error): void;
8686

8787
/**
8888
* Called whenever the router updates its state in response to URL changes.
8989
*/
90-
onUpdate?();
90+
onUpdate?(): void;
9191

9292
/**
9393
* 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} />}.
@@ -165,7 +165,7 @@ declare module ReactRouter {
165165
*
166166
* @param {React.MouseEvent} event **NOTE** I'm assuming this will be a click event.
167167
*/
168-
onClick?(event: React.MouseEvent);
168+
onClick?(event: React.MouseEvent): any;
169169
}
170170

171171
/**
@@ -228,47 +228,47 @@ declare module ReactRouter {
228228
*
229229
* @param {LocationDescriptor} pathOrLoc
230230
*/
231-
push(pathOrLoc: LocationDescriptor);
231+
push(pathOrLoc: LocationDescriptor): void;
232232

233233
/**
234234
* Identical to push except replaces the current history entry with a new one.
235235
*
236236
* @param {LocationDescriptor} pathOrLoc
237237
*/
238-
replace(pathOrLoc: LocationDescriptor);
238+
push(pathOrLoc: LocationDescriptor): void;
239239

240240
/**
241241
* Go forward or backward in the history by n or -n.
242242
*
243243
* @param {number} n
244244
*/
245-
go(n: number);
245+
go(n: number): void;
246246

247247
/**
248248
* Go back one entry in the history.
249249
*/
250-
goBack();
250+
goBack(): void;
251251

252252
/**
253253
* Go forward one entry in the history.
254254
*/
255-
goForward();
255+
goForward(): void;
256256

257257
/**
258258
* Stringifies the query into the pathname, using the router's config.
259259
*
260260
* @param {LocationDescriptor} pathOrLoc
261261
* @param {Query} query
262262
*/
263-
createPath(pathOrLoc: LocationDescriptor, query: Query);
263+
createPath(pathOrLoc: LocationDescriptor, query: Query): void;
264264

265265
/**
266266
* Creates a URL, using the router's config. For example, it will add #/ in front of the pathname for hash history.
267267
*
268268
* @param {LocationDescriptor} pathOrLoc
269269
* @param {Query} query
270270
*/
271-
createHref(pathOrLoc: LocationDescriptor, query: Query);
271+
createHref(pathOrLoc: LocationDescriptor, query: Query): void;
272272

273273
/**
274274
* Returns true or false depending on if the pathOrLoc is active. Will be true for every route in the route branch matched (child route is active, therefore parent is too), unless indexOnly is specified, in which case it will only match the exact path.
@@ -361,7 +361,7 @@ declare module ReactRouter {
361361
* @param {Location} location
362362
* @param {(err: Error, routes: PlainRoute[]) => void} callback
363363
*/
364-
getChildRoutes?(location: Location, callback: (err: Error, routes: PlainRoute[]) => void);
364+
getChildRoutes?(location: Location, callback: (err: Error, routes: PlainRoute[]) => void): void;
365365

366366
/**
367367
* The index route. This is the same as specifying an <IndexRoute> child when using JSX route configs.
@@ -394,7 +394,8 @@ declare module ReactRouter {
394394
* @param {Location} location
395395
* @param {(err: Error, route: PlainRoute) => void} callback
396396
*/
397-
getIndexRoute?(location: Location, callback: (err: Error, route: PlainRoute) => void);
397+
398+
getIndexRoute?(location: Location, callback: (err: Error, route: PlainRoute) => void): void;
398399
}
399400

400401
export interface IRedirectProps extends IIndexRedirectProps {
@@ -504,7 +505,7 @@ declare module ReactRouter {
504505
* @param {Location} location
505506
* @param {(error: Error, component: Component<any>) => void} callback
506507
*/
507-
getComponent?(location: Location, callback: (error: Error, component: ReactComponent<any>) => void);
508+
getComponent?(location: Location, callback: (error: Error, component: ReactComponent<any>) => void): void;
508509

509510
/**
510511
* Same as components but asynchronous, useful for code-splitting.
@@ -517,7 +518,7 @@ declare module ReactRouter {
517518
* @param {Location} location
518519
* @param {(error: Error, components: { [name: string]: Component<any> }) => void} callback
519520
*/
520-
getComponent?(location: Location, callback: (error: Error, components: { [name: string]: ReactComponent<any> }) => void);
521+
getComponent?(location: Location, callback: (error: Error, components: { [name: string]: ReactComponent<any> }) => void): void;
521522

522523
/**
523524
* Routes can be nested, this.props.children will contain the element created from the child route component. Please refer to the Route Configuration since this is a very critical part of the router's design.
@@ -535,7 +536,7 @@ declare module ReactRouter {
535536
* @param {(location: LocationDescriptor) => void} replace
536537
* @param {() => void} [callback]
537538
*/
538-
onEnter?(nextState: any, replace: (location: LocationDescriptor) => void, callback?: () => void);
539+
onEnter?(nextState: any, replace: (location: LocationDescriptor) => void, callback?: () => void): void;
539540

540541
/**
541542
* Called when a route is about to be exited.
@@ -747,7 +748,7 @@ declare module ReactRouter {
747748
* @param {routes: RouteConfig}
748749
* @param {(error:Error, redirectLocation:Location, renderProps : Object) => void} callback
749750
*/
750-
export function match({routes: RouteConfig}, callback: (error: Error, redirectLocation: Location, renderProps: Object) => void);
751+
export function match({routes: RouteConfig}, callback: (error: Error, redirectLocation: Location, renderProps: Object) => void): void;
751752

752753
/**
753754
* Creates and returns an array of routes from the given object which may be a JSX route, a plain object route, or an array of either.

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"module": "commonjs",
55
"jsx": "react",
66
"allowSyntheticDefaultImports": true,
7-
"noEmit": true
7+
"noEmit": true,
8+
"noImplicitAny": true
89
},
910
"exclude": [
1011
"typings"
1112
]
12-
}
13+
}

0 commit comments

Comments
 (0)