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

Cerrado
#3,080 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.

  • #3085 de @alantriesagain — abierto
  • #3109 de @ctate — abierto

Evaluación

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

Línea de trabajo

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.

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

Descripción

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.

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.