microsoft / microsoft/TypeScript

Unexpected distributive behaviour on type alias

オープン
#62,761 コメント 6 件 リアクション 1 件 担当者 1 名 GitHub で見る

@ahejlsberg がすでに取り組んでいます。

2025年11月17日 から。

Needs Investigation
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

### 🔎 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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。