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
This commit is contained in:
DaIgeb
2017-05-05 10:11:16 -07:00
committed by Mohamed Hegazy
parent 221fdba61b
commit 585178525c
2 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -12,6 +12,7 @@
// Tanguy Krotoff <https://github.com/tkrotoff>
// Huy Nguyen <https://github.com/huy-nguyen>
// Jérémy Fauvel <https://github.com/grmiade>
// Daniel Roth <https://github.com/DaIgeb>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -84,7 +85,7 @@ export interface StaticRouterProps {
export class StaticRouter extends React.Component<StaticRouterProps, undefined> {}
export interface SwitchProps {
children?: JSX.Element | JSX.Element[];
children?: React.ReactNode;
location?: H.Location;
}
export class Switch extends React.Component<SwitchProps, undefined> {}
+6
View File
@@ -2,12 +2,18 @@ import * as React from 'react';
import { BrowserRouter, Redirect, Route, Switch } from 'react-router-dom';
const Home = () => <h2>Home</h2>;
const About = () => <h2>About</h2>;
const User = () => <h2>User</h2>;
const SwitchTest = () => (
<BrowserRouter>
<Switch>
<Redirect exact from="/" to="/home"/>
<Route path="/home" component={Home}/>
{[
<Route path="/user" component={User}/>,
<Route path="/about" component={About}/>
]}
</Switch>
</BrowserRouter>
);