From f71b4a0526509070732d2dc4ff5dddbcc8e984fa Mon Sep 17 00:00:00 2001 From: Clay Miller Date: Sun, 27 Oct 2019 22:11:25 -0400 Subject: [PATCH] Make 'Omit' a distributive conditional type to support union prop types. Fixes #39300. (#39323) --- types/styled-components/index.d.ts | 2 +- types/styled-components/test/index.tsx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/styled-components/index.d.ts b/types/styled-components/index.d.ts index 8faaa640bb..a483f96b05 100644 --- a/types/styled-components/index.d.ts +++ b/types/styled-components/index.d.ts @@ -346,7 +346,7 @@ export type ThemedCssFunction = BaseThemedCssFunction< >; // Helper type operators -type Omit = Pick>; +type Omit = T extends any ? Pick> : never; type WithOptionalTheme

= Omit & { theme?: T; }; diff --git a/types/styled-components/test/index.tsx b/types/styled-components/test/index.tsx index a2a8f7f1a4..eaa43ee491 100644 --- a/types/styled-components/test/index.tsx +++ b/types/styled-components/test/index.tsx @@ -1052,8 +1052,7 @@ function unionTest() { font-size: ${props => props.kind === 'book' ? 16 : 14} `; - // undesired, fix was reverted because of https://github.com/Microsoft/TypeScript/issues/30663 - ; // $ExpectError + ; ; // $ExpectError }