Skip to content

Omit causes function to lose contextual typing #63225

Description

🔎 Search Terms

implicit any contextual type

🕗 Version & Regression Information

  • This changed between versions 5.9.3 and 6.0 - rc

⏯ Playground Link

Playground Link

💻 Code

declareletx: {function: string}exporttypeAssertableState<T>={[PinkeyofTasP]: (value: T[P])=>void;}declarefunctionassert_state<Textendsobject>(o: T,state: AssertableState<T>): void;assert_state(x,{function: v=>{}// v is string})declarefunctionassert_state_bad<Textendsobject>(o: T,state: Omit<AssertableState<T>,"">): void;assert_state_bad(x,{function: v=>{}// error - v is implictly any})

🙁 Actual behavior

The call to assert_state_bad fails because v is implicitly typed as any

🙂 Expected behavior

Either should pass as in 5.9.3

Additional information about the issue

  • Works without the Omit
  • Works without the as P in the mapped type. (original mapping was more complicated, but identity mapping seems to trigger it too)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs InvestigationThis issue needs a team member to investigate its status.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions