Commit Graph
27 Commits
Author SHA1 Message Date
Youen 2707abc38a [react-router] added possibility to specify component props in route definitions, and to specify the type of this.props.route.props when implementing such a component (#22954)
* [react-router] fixed lint error due to implicit any in CustomLink test

* [react-router] added possibility to specify component props in route definitions, and to specify the type of this.props.route.props when implementing such a component

Example:

/* component definition */
interface Props { foo: string }
class MyComponent extends React.Component<RouteComponentProps<void,void,Props>, State> {
    /* here you can use this.props.route.props.foo */
}

/* route configuration */
<Route path="/my-path" component={MyComponent} props={{ foo: 'bar' }}>

* - fixed lint errors related to T[] instead of Array<T>
- added default type for ComponentProps in RouteComponentProps<P,R,ComponentProps>, so that it stays compatible with existing code

* [react-router] added default route props type (any) so that this new feature is fully backward compatible

* [react-router] fixed lint errors (T[] instead of Array<T> for non-generic types)
2018-01-24 08:16:00 -08:00
Jeremy Fauvel 4b925d212f [react-router] Remove useless definition for withRouter as decorator (#21799)
* [react-router] Remove useless definition for `withRouter` as decorator

* Add regression test
2017-12-19 22:35:40 +00:00
Jeremy Fauvel 3289762cca [react-router] Improve withRouter return type (#21329)
* [react-router] Improve withRouter return type

* Fix lint errors

* Fix dependencies version
2017-11-23 19:33:27 +00:00
Pasi Eronen 6e4ad80b70 react-router/react-router-dom: fix typing for getUserConfirmation and Prompt props 2017-11-21 12:41:42 +02:00
Robin Zoň 5b22167627 React.Components template arguments fixed (#21356) 2017-11-08 22:35:07 +00:00
Diogo Franco 399af551e6 [react-router] Fix for --strictFunctionTypes (#20746)
* [react-router] Fix for --strictFunctionTypes

It seems it's not possible for a SFC to conform to React.ComponentType<RouteComponentProps<any> | {}> with both strictFunctionTypes and strictNullChecks (they have to either be `Partial<RouteComponentProps<any>>` or `{}`).

The whole point of the `| {}` is to allow for components that have defaulted `Props` / don't use any `Props` anyway, so adding it as another listed type should work.

* Fix dtslint errors
2017-10-20 08:28:12 -07:00
Egor Shulga aa596d8723 Move decorator signature comment to the top of the line. 2017-08-11 17:22:56 +03:00
Egor Shulga 1d8a7055cf add withRouter decorator 2017-08-09 15:03:53 +03:00
Ryan Cavanaugh fec422d226 Merge pull request #17611 from tkrotoff/react-router-component
Refactoring: use React.ComponentType
2017-07-10 09:41:41 -07:00
mtpc bc710a72d6 Make Route component extensible
Shouldn't have any impact whatsoever in existing codebases due to default generics
2017-07-04 21:17:49 +02:00
Tanguy Krotoff 552051f56f Default props should be {}, not undefined or void 2017-06-29 14:00:18 +02:00
Tanguy Krotoff 51e7287c86 React.SFC<...> | React.ComponentClass<...> => React.ComponentType<...> 2017-06-29 14:00:00 +02:00
Tanguy Krotoff ea9de8a518 Replace React.Component<(.*), (any|void|\{\}|null)> by React.Component<$1>
+ many manual adjustments
2017-06-19 13:35:50 +02:00
Tanguy Krotoff eeb262e1d8 Update react to TypeScript 2.3 2017-06-19 13:34:54 +02:00
Michael Strobel 3b1ba96df2 [react-router] add RouteComponentProps.staticContext (#16812)
* [react-router] add RouteComponentProps.staticContext

* [react-router] revert RouteConfig test file

* [react-router] Add example for StaticRouter and staticContext
2017-05-31 21:56:38 -07:00
Daniel Rosenwasser 65cfdaef94 Fixed the type of 'children' for 'Route' in 'react-router'. 2017-05-30 01:01:22 -07:00
Yui 1d19461b6e Update state type parameter (#16361) 2017-05-05 16:36:51 -07:00
DaIgeb fe1b612ef0 Allow component props for withRouter (#16339) 2017-05-05 10:38:55 -07:00
DaIgeb 585178525c Update SwitchProps to support typescript 2.3 (#16340)
SwitchProps.children is too strict for projects using typescript 2.3.
With typescript 2.3 the children could be made mandatory, but this will
break backwards compatibility with any ts 2.2 user
2017-05-05 10:11:16 -07:00
Kanchalai Tanglertsampan eeff64b04e Update library files with children check 2017-05-04 16:31:27 -07:00
Denis ddb6d939c3 TS Linting react-router (#16240)
- Using default `dtslint/dt.json` for linting
2017-05-01 13:47:36 -07:00
Jeremy Fauvel cb42760188 Add missing Redirect props (#16195)
Add an optional extended description…
2017-04-28 10:54:07 -07:00
Michael Strobel 4a2542e4af react-router MemoryRouter.initialEntries
* Use History.LocationDescriptor[]
* Add example
2017-03-29 08:07:50 +08:00
Huy Nguyen 7da5a5871f Update contributor credits 2017-03-28 14:02:24 -04:00
Huy Nguyen 3e626b8949 Add type of context for react-router & react-router-dom
The `Router` component passes a context object down to children.  This
commit adds the type definition for this context object for children of
`Router` to use.
2017-03-28 13:57:16 -04:00
Budry e77796aee3 StaticRouter has no any history props 2017-03-24 23:59:28 +01:00
Andy Hanson 354cec620d Move all packages to a types directory 2017-03-24 14:27:52 -07:00