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!
This commit is contained in:
Nathan Shively-Sanders
2020-12-09 16:59:42 -08:00
committed by GitHub
parent ba94778eba
commit 5af8fdf215

View File

@@ -158,7 +158,7 @@ export type AnyStyledComponent =
| StyledComponent<any, any, any>;
export type StyledComponent<
C extends string | React.ComponentType<any>,
C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
T extends object,
O extends object = {},
A extends keyof any = never