Skip to content

styled-components broken by #41841 #41886

@sandersn

Description

@sandersn

Found by overnight DT run for #41841

Here's a standalone repro; it's not minimal but it doesn't depend on anything else.

interface FunctionComponent<P = {}> {
    defaultProps?: Partial<P>;
}
type ComponentType<P = {}> = FunctionComponent<P>;
export type KProps<C extends string | ComponentType<any>> =
    object extends object ? Omit<C, any> & Partial<C> : never;
export interface StyledK<C extends string | ComponentType<any>> {
    (props: KProps<C>): never
}
type Constraint<T extends ComponentType> = T ;
export type StyledComponentInnerComponent<C> = C extends StyledK<infer I> ? I : C;
export type SProblem<C extends ComponentType<any>> = C extends StyledK<any> ? Constraint<StyledComponentInnerComponent<C>> : number;

Expected behavior:
No error, as in 4.1.

Actual behavior:
Error in SProblem on Constraint<StyledComponentInnerComponent<C>>:

error TS2344: Type 'StyledComponentInnerComponent<C>' does not satisfy the constraint 'ComponentType<{}>'.
  Type 'string | ComponentType<any> | C' is not assignable to type 'FunctionComponent<{}>'.
    Type 'string' has no properties in common with type 'FunctionComponent<{}>'.
      Type 'string | ComponentType<any>' is not assignable to type 'FunctionComponent<{}>'.
        Type 'string' has no properties in common with type 'FunctionComponent<{}>'.

Metadata

Metadata

Assignees

Labels

Breaking ChangeWould introduce errors in existing codeWorking as IntendedThe behavior described is the intended behavior; this is not a bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions