From 5af8fdf21579b2afcb42b447b2def9b5dcc8c540 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 9 Dec 2020 16:59:42 -0800 Subject: [PATCH] StyledComponent: More accurate component constraint (#50046) This change makes styled-components pass compilation on Typescript 4.2, which correctly propagates type parameter constraints through certain complex conditional types. Old versions of typescript just dropped the constraint by mistake, so this inconsistency was just not checked before. I'm not certain this is the right solution; in particular, it may be a lot slower. I hope not, because I have no idea what the right fix is otherwise! --- types/styled-components/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/styled-components/index.d.ts b/types/styled-components/index.d.ts index 9fa96b974f..998c154f85 100644 --- a/types/styled-components/index.d.ts +++ b/types/styled-components/index.d.ts @@ -158,7 +158,7 @@ export type AnyStyledComponent = | StyledComponent; export type StyledComponent< - C extends string | React.ComponentType, + C extends keyof JSX.IntrinsicElements | React.ComponentType, T extends object, O extends object = {}, A extends keyof any = never