Skip to content

[@types/react] 16.8.5 breaks assignability of components that use Pick, Exclude, generics and/or conditional types #33461

@NiGhTTraX

Description

@NiGhTTraX

Example code: https://github.com/NiGhTTraX/react-connect-state/blob/132c3a8e8ad880f79078127ce149758d5c324804/src/connect.tsx#L29 that works in 16.8.4. I apologize for not providing a simpler example but I tried reducing it and couldn't reproduce so I'm not sure which part of my code is causing this. I have manually reverted the commit below and my code compiles again.

Error:(29, 15) TS2322: Type 'Readonly<PropsWithChildren<Pick<ViewProps, Exclude<keyof ViewProps, K>>>>' is not assignable to type 'IntrinsicAttributes & Pick<ViewProps, Exclude<keyof ViewProps, K>> & { children?: ReactNode; }'.
  Type 'Readonly<PropsWithChildren<Pick<ViewProps, Exclude<keyof ViewProps, K>>>>' is not assignable to type 'Pick<ViewProps, Exclude<keyof ViewProps, K>>'.
    Type 'PropsWithChildren<Pick<ViewProps, Exclude<keyof ViewProps, K>>>[P]' is not assignable to type 'ViewProps[P]'.
      Type 'PropsWithChildren<Pick<ViewProps, Exclude<keyof ViewProps, K>>>' is not assignable to type 'ViewProps'.

Caused by b5200f6#diff-96b72df8b13a8a590e4f160cbc51f40c. I don't understand why though, maybe the way Readonly distributes over the new type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions