Skip to content

Inconsistent subtyping between union of objects and object with union property when the number of variants > 25Β #51677

Closed
@tsuburin

Description

@tsuburin

Bug Report

πŸ”Ž Search Terms

object union subtyping

πŸ•— Version & Regression Information

  • This changed between versions v3.3.3 and v3.5.1

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

The exact same code with that of playground above.

type X25 =
  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25
type X26 = X25 | 26

type Y25 =
  | { x: 1 }
  | { x: 2 }
  | { x: 3 }
  | { x: 4 }
  | { x: 5 }
  | { x: 6 }
  | { x: 7 }
  | { x: 8 }
  | { x: 9 }
  | { x: 10 }
  | { x: 11 }
  | { x: 12 }
  | { x: 13 }
  | { x: 14 }
  | { x: 15 }
  | { x: 16 }
  | { x: 17 }
  | { x: 18 }
  | { x: 19 }
  | { x: 20 }
  | { x: 21 }
  | { x: 22 }
  | { x: 23 }
  | { x: 24 }
  | { x: 25 }
type Y26 = Y25 | {x: 26}

type TestXY25 = {x: X25} extends Y25 ? true: false // true
type TestXY26 = {x: X26} extends Y26 ? true: false // false <--

type TestYX25 = Y25 extends {x: X25} ? true: false // true
type TestYX26 = Y26 extends {x: X26} ? true: false // true

πŸ™ Actual behavior

Type {x: T1 | ... | TN} is not treated as a subtype of {x: T1} | ... | {x: TN} when N > 25

πŸ™‚ Expected behavior

It should be treated as a subtype. Or at least, the behavior should not change between N <= 25 and N > 25

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