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

Cerrado
#3,078 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@alantriesagain ya está trabajando en esto.

Desde el 6/11/2026.

  • #3083 de @alantriesagain — abierto
  • #3104 de @ctate — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript, typescript
Área
compilers

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
6.5k
Forks
212
Merge medio
13 h 2 min
PR fusionados (30 d)
798

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de vercel-labs/scriptc

Todos los issues de vercel-labs/scriptc

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.