From 585178525c00f19e930516caaf90ecc5acbe50f0 Mon Sep 17 00:00:00 2001 From: DaIgeb Date: Fri, 5 May 2017 19:11:16 +0200 Subject: [PATCH] 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 --- types/react-router/index.d.ts | 3 ++- types/react-router/test/Switch.tsx | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 81244caa29..a955271aae 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -12,6 +12,7 @@ // Tanguy Krotoff // Huy Nguyen // Jérémy Fauvel +// Daniel Roth // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -84,7 +85,7 @@ export interface StaticRouterProps { export class StaticRouter extends React.Component {} export interface SwitchProps { - children?: JSX.Element | JSX.Element[]; + children?: React.ReactNode; location?: H.Location; } export class Switch extends React.Component {} diff --git a/types/react-router/test/Switch.tsx b/types/react-router/test/Switch.tsx index 6a8b50f247..fe959504ce 100644 --- a/types/react-router/test/Switch.tsx +++ b/types/react-router/test/Switch.tsx @@ -2,12 +2,18 @@ import * as React from 'react'; import { BrowserRouter, Redirect, Route, Switch } from 'react-router-dom'; const Home = () =>

Home

; +const About = () =>

About

; +const User = () =>

User

; const SwitchTest = () => ( + {[ + , + + ]} );