Promise.all result is treated as possibly undefined, widening mapped rows

クローズ
#3,080 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

2026年11月6日 から。

  • #3085 @alantriesagain による — オープン
  • #3109 @ctate による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
47/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, typescript
領域
compilers

調査の方向性

Start with the optional-read analysis that assigns facts to Promise.all results, then inspect the TypeScript and JavaScript corpus cases async-early-return-promise-all.ts and async-early-return-promise-all.js. Compare their SC9001 failures with the reported passing cases 4948 and 4956, and check the Promise.allSettled behavior. Done means the reported Promise.all cases compile without the internal errors while Promise.allSettled remains conservative.

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

説明

Promise.all result is treated as possibly undefined, widening mapped rows

The optional-read analysis assumes that any Promise.all result can hold undefined. That fact lands on the element ABI of the array the result is stored in. After

rows = await Promise.all(rows.map((row) => load(row, includes)));

every array of that element type counted as possibly holding undefined. The map callback's parameter widened, the parameter of load widened with it, and an early return row made load return Promise<Row | undefined>. The callback's return became Promise<Row> | undefined, which nothing converts to, and the build failed with SC2003. In JavaScript the site was deferred, and a computed-key write through a loop binding over the result then failed validation.

A typed promise settles with a value of its own type. Every conversion into it checks the value, and the element ABI already records whether that type admits undefined. The Promise.all result therefore holds undefined only where an entry is a hole or undefined. Promise.allSettled keeps the conservative fact.

On 0.4.8, the TypeScript and JavaScript forms in our corpus (async-early-return-promise-all.ts and async-early-return-promise-all.js) still fail with SC9001 internal compiler errors around %recordValue and a bare null at row[field] = null. The separate JavaScript array and indexOf precision programs (4948 and 4956) now pass. The same failures reproduce on main (979a65246).

I opened #TBD with a patch for the Promise.all fact.

主要言語
TypeScript
スター
6.5k
フォーク
212
平均マージ
13時間 2分
マージ済み PR(30日)
798

環境構築

はじめの一歩

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

vercel-labs/scriptc のほかの issue

vercel-labs/scriptc の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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