Async function with a typed result rejects a returned checked-dynamic promise

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

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

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

2026年11月6日 から。

  • #3083 @alantriesagain による — オープン
  • #3104 @ctate による — オープン

評価

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

調査の方向性

The report provides a JavaScript reproduction and says the failure also occurs on main at commit 979a65246, but names no implementation files or tests. Start by tracing how typed async function returns and concise async arrow bodies handle checked-dynamic values, then find the related compiler tests. Done means both forms adopt returned promises with the stated turn order and settle other values without an extra turn.

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

説明

Async function with a typed result rejects a returned checked-dynamic promise

An async function whose result is typed checks a returned checked-dynamic value against that type directly. When the value is a promise, JavaScript resolves the function's promise with that promise: the promise is adopted, not converted as a plain value.

In our model layer, uploadFiles takes a schema whose type does not map, so its call is checked-dynamic. return uploadFiles(...) from a typed async function failed at run time with expected object at $, got Promise. Node resolves the returned promise.

/** @returns {Promise<{ id: string }>} */
async function load() {
  const opaque = (value) => value;
  return opaque(Promise.resolve({ id: "a" }));
}

load().then((value) => console.log(value.id));

On 0.4.8, the compiled program throws Uncaught TypeError: expected object at $, got Promise; Node prints a. The same failure reproduces on main (979a65246).

The same rule should apply to concise async arrow bodies. A promise behind the dynamic value should be adopted with the turn order of a returned typed promise: the then job's turn, then its settlement, after every crossed finally and outside the function's own catch. Any other value should settle the function at once, with no extra turn.

I opened #TBD with a patch for both forms.

主要言語
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 を短くまとめたダイジェスト。