microsoft / microsoft/TypeScript

Unexpected distributive behaviour on type alias

Aperta
#62,761 6 commenti 1 reazione 1 assegnatario Vedi su GitHub

@ahejlsberg ci sta già lavorando.

Dal 17/11/2025.

Needs Investigation
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

### 🔎 Search Terms

distributive conditional types, naked type parameter, type alias, unions

### 🕗 Version & Regression Information

- This changed between versions 3.8.3 and 3.9.7.
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about distributive conditional types, naked type parameter, type alias, unions.

### ⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.3#code/C4TwDgpgBAaghgGwK7QLxQIxQD5QEwBQBokUAKhALZhToDa8yEAulBAB7AQB2AJgM5Q6AS24AzCACdYzAlCgB+WG048BUJNwDW3APYB3bnPmKhMADSxEKWSagAuKNwgA3KccfO3koiWgAlCH4kBGBacioaAHoolUgAYzC6DEssXDxWXDo8VJx8WxMYgD0FIA

### 💻 Code

```ts
type Value = 1 | 2

type Result = [Value] extends [infer V]
? V extends unknown
? [V, Value]
: never
: never
```

### 🙁 Actual behavior

```ts
[1, 1] | [2, 2]
```

### 🙂 Expected behavior

```ts
[1, 1 | 2] | [2, 1 | 2]
```

### Additional information about the issue

It shouldn't work the way it does now, for several reasons:
1. Value is not naked type parameter.
2. Using brackets, distributive behaviour must be disabled.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.