microsoft / microsoft/TypeScript

`forEachChild` is hard to use with async API

オープン
#64,126 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

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

2026年9月1日 から。

Domain: API
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

評価

この issue はまだ評価されていません。

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

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