Skip to content

Non-naked type parameter match still has distributive behavior #43727

Closed
@strblr

Description

@strblr

Bug Report

🔎 Search Terms

Generic types, distributive unions, extends, naked type parameter

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about distributivity with naked type parameters.

⏯ Playground Link

Playground link with relevant code

💻 Code

type A<T> = T;
type B<T> = A<T> extends true ? "X" : "Y";
type C = B<true | false>; // "X" | "Y" (??)

🙁 Actual behavior

A<T> in B distributes types and returns the union of the results.

🙂 Expected behavior

Since T is not naked in A<T>, I was expecting distributivity to go away, like in :

type A<T> = T extends infer U ? U : never;
type B<T> = A<T> extends true ? "X" : "Y";
type C = B<true | false>; // "Y"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions