Skip to content

Narrowing works incorrectly when destructuringΒ #50604

Closed as not planned
Closed as not planned
@tatomyr

Description

@tatomyr

Bug Report

πŸ”Ž Search Terms

destructure, union, narrowing

πŸ•— Version & Regression Information

v.4.7.4, v4.8.0-beta.

⏯ Playground Link

Playground link

πŸ’» Code

const removeX = <T, X>({x, ...rest}: T & {x: X}): T => rest

πŸ™ Actual behavior

It produces the following error:

Type 'Omit<T & { x: X; }, "x">' is not assignable to type 'T'.
  'T' could be instantiated with an arbitrary type which could be unrelated to 'Omit<T & { x: X; }, "x">'.

πŸ™‚ Expected behavior

There should be no error since Omit<T & { x: X; }, "x"> is essentially equal to T.

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