microsoft / microsoft/TypeScript

`forEachChild` is hard to use with async API

Abierto
#64,126 0 comentarios 0 reacciones 1 asignado Ver en GitHub

@andrewbranch ya está trabajando en esto.

Desde el 1/9/2026.

Domain: API
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

If you try to use the async API, it's a challenge today. The API provides a synchronous tree traversal function (forEachChild), but pulling on semantic information is asynchronous.

The problem isn't the mixture itself - it's that forEachChild stops walking when the visitor function returns a truthy result. This makes it impractical to use with async APIs because every async function returns a Promise which is truthy.

The current workarounds are a little awkward, basically introducing a layer of indirection between the traversal function and forEachChild that uses intermediate queues.

I'm not sure if there's an ideal solution - there's at least two problems right now:

  • it feels like we could benefit from a forEachChildAsync or something like that.
  • using forEachChild is a foot-gun if you've decided to use the async API.

Guía de contribución

Abrir la guía de contribución

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.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.