Repository: TypeScript
Issue: Expression produces a union type that is too complex to represent
Labels: Needs Investigation,Has Repro

# Bug Report

### 🔎 Search Terms

"Expression produces a union type that is too complex to represent"
(found #33130 which seems unrelated as it has been fixed)

### 🕗 Version & Regression Information

- Present from 4.1.5 to 5.0.2 in playground.

### ⏯ Playground Link

[Example in Playground](https://www.typescriptlang.org/play?ts=5.0.2#code/GYVwdgxgLglg9mABBOBbADiKBTAJgHgDlFsAPHMXAZ0QGtsBPOYRAGQQHMALAQ0qoB8ACgBQiROgBOcdNklQGALjade-ANqEAuuoCMWgDRjEVWRBjAYeZezDc+1TToAMWkQEpEAb2NSZchQA6FAwsbCFTbHNLPHcAbhEAXxERGDAcSWAeCGxEAAVpWXkGfAAVAW9jEMwcZSEANx4AGxBsZVLPAF4K0oTkkQVZRAB1SR50IrKKzsR1UoN8woCS8q0E1PS5LJyVOzVqSvEAImAEKABaLNQYJoYj5VHxyYAxHmvbgQTj0-TzqhgAF7Ye4jMYTOT4ADKgOwn2MJzOfygkmwUAgXBBj3BkihyNR6Lh30RjUkMD4Fwg4yomLBkwAwlTCYgEb8SWTftgeFQLlz2TSnhCAKJcqAAQX+fCZLIubPJ5yaMA4PCgIBR1IetIhrEVytV2EEX2ZPxlPFJcrAIFQchgEH52KIlutEClxvOst+6Dg-1gCDtkzyXpgPrALsRAHdsIquFA-RDhpHuFA4f0IE0uTQANKMMNwSQEDMkcjYfgmZFpDgVHziegMHN55QZw0oMDcyQgaC5oQ1uu4BueKviRBQLgwKiBbu53CIGYTvOG5L9Qa5V7vBjTxBZ2uT-BHKjW4BHOFLxDQoHrzc9ndNYscYeHhLHyF4tFcafGAA+G+z26ORRy6R4DhgQED8vy3PMdxAJpkR4c5m1wYs91wQ9QIvH8yBguCEAQls8BQ8RPzQiCjngxC8JAgiwMvXdsGuLDKDI5CKMQQjv2IsBc1QZp8JYqifz3OiyHQBxyNQtiCCOISRKYsTwIkjCxnOKSGJkyiiIkqDMOUhCmIfBghgZdAaBmdSdw4yQuKae8Bn03JhW5cV2TfNTxLMzjuOY1i5J3AArUcAHYAA4eK86i-KoQKAGYQr44jwoATmcGLTKOcLnAAFmS1zdxgDAFRiVTeJSmDcCDeAwA82TqL8T15HK5pzjDGBcDvTzYok0AmiaRrmtaqqfzbAAjO4j1stgdRVNVnKK7KOLAYD+vY9yrLalKQlQBB5QmvVqVW2a4Cw1ANrALalUm-Usu8o5SqoCAUWDU0GFO3U1Uu6iOPOG67tRerJCehUzp2t6fxHblcxtBqAZei69quj7QagcHKW6qHzt2xaJObHByBASqXLhg6sYw3GVr0oZCEdUkIGm0Kf3MyzgeIhUwHLc4LVQdH8eouAmmoBRrzZy1OZmq6atzB7uvZ4XaeIqAeEGqDTUFjnGYk0rAIQBrgDGaByul9qd25bJ6FwS4deDfWUsnNI8ZF6iqDTKguDwc4gWkazjwDb1yvPfaLI8u3+JAQbD0D4iqBAIoPbG+MoygGmDaOdnBrkVW3P9laMZ3QaecKmWJJz3nU9h6iAejYuEiAA)

### 💻 Code

```ts repro
function computed<N extends keyof Longhands>(
  property: Longhands[N][1],
  specified: Longhands[N][0]
) {
  // error happens on this line
  property.compute(specified);
}

interface Property<T> {
  compute: (value: T) => T;
}

type Wrapper<T> = [T, Property<T>];

interface Longhands {
  "font-family": Wrapper<Family>;
  "font-size": Wrapper<Size>;
  "font-stretch": Wrapper<Stretch>;
  "font-variant-caps": Wrapper<Caps>;
  "font-variant-east-asian": Wrapper<EastAsian>;
  "font-variant-ligatures": Wrapper<Ligatures>;
  "font-variant-numeric": Wrapper<Numeric>;
  "font-variant-position": Wrapper<Position>;
  "font-weight": Wrapper<Weight>;
}

class Keyword<K extends string> {
  keyword: K;
  constructor(keyword: K) {
    this.keyword = keyword;
  }
}

type Family = Keyword<"serif">;
type Size = Keyword<"length">;
type Stretch =
  | Keyword<"percentage">
  | Keyword<"ultra-condensed">
  | Keyword<"extra-condensed">
  | Keyword<"condensed">
  | Keyword<"semi-condensed">
  | Keyword<"normal">
  | Keyword<"semi-expanded">
  | Keyword<"expanded">
  | Keyword<"extra-expanded">
  | Keyword<"ultra-expanded">;
type Caps = Keyword<"normal">;
type EastAsian =
  | Keyword<"normal">
  | Keyword<"jis78">
  | Keyword<"jis83">
  | Keyword<"jis90">
  | Keyword<"jis04">
  | Keyword<"simplified">
  | Keyword<"traditional">
  | Keyword<"proportional-width">
  | Keyword<"full-width">
  | Keyword<"ruby">;
type Ligatures =
  | Keyword<"none">
  | Keyword<"normal">
  | Keyword<"common-ligatures">
  | Keyword<"no-common-ligatures">
  | Keyword<"discretionary-ligatures">
  | Keyword<"no-discretionary-ligatures">
  | Keyword<"historical-ligatures">
  | Keyword<"no-historical-ligatures">
  | Keyword<"contextual">
  | Keyword<"no-contextual">;
type Numeric =
  | Keyword<"normal">
  | Keyword<"lining-nums">
  | Keyword<"oldstyle-nums">
  | Keyword<"proportional-nums">
  | Keyword<"tabular-nums">
  | Keyword<"diagonal-fractions">
  | Keyword<"stacked-fractions">
  | Keyword<"ordinal">
  | Keyword<"slashed-zero">;
type Position = Keyword<"normal"> | Keyword<"sub"> | Keyword<"super">;
type Weight =
  | Keyword<"number">
  | Keyword<"normal">
  | Keyword<"bold">
  | Keyword<"bolder">
  | Keyword<"lighter">;
```

Note: interestingly, I detected the error in the much more complex real code of [Alfa](https://github.com/Siteimprove/alfa) where it only triggers in TS 4.9.3, but not in 4.8.4 🤔 I am not sure which simplification happens in my real code to keep the union smaller…

### 🙁 Actual behavior

The code produces the error:
> Expression produces a union type that is too complex to represent

### 🙂 Expected behavior

The union should be around 50 items big, far below the limit.