microsoft / microsoft/TypeScript

bug(lib): Explicitly stating wrong return type of `Promise.then` without arguments results in no error

オープン
#63,244 コメント 5 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

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

説明

### 🔎 Search Terms

- silenced Promise resolution type mismatch
- Promise generic explicit no error
- no error when Promise type is specified explicitly
- generic inside optional argument

### 🕗 Version & Regression Information

TS v3.3.3 correctly detects the error, which is the earliest Playground version. All other Playground versions silence the error.

### ⏯ Playground Link

https://www.typescriptlang.org/play/?ts=6.0.0-dev.20260312#code/MYewdgzgLgBFCm0BcMAKAnEBbAlheAPNOjmAOYB8MAvGprvgHTqIgA2AbvABQCMAlIygALeGG78A3EA

### 💻 Code

```ts
const test: Promise = Promise.resolve(1).then();
```

### 🙁 Actual behavior

No TypeScript errors.

### 🙂 Expected behavior

I expected a similar error to what TS v3.3.3 yields:
> Type `Promise` is not assignable to type `Promise`. Type `number` is not assignable to type `string`.

### Additional information about the issue

_No response_

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

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

はじめの一歩

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

調査の方向性

リンクされた TypeScript Playground で報告された例を再現し、現在の動作を issue に記載されている TypeScript 3.3.3 の結果と比較します。引数なしで呼び出された Promise.then の型チェック経路を追跡します。完了条件は、明示的な Promise への代入で Promise との不一致が報告されることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

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

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