mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
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:
Vendored
+2
-1
@@ -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> {}
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user