microsoft / microsoft/TypeScript

`controller.byobRequest` type incorrectly says value is possibly null while `autoAllocateChunkSize` is present.

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

まだ誰も着手していません。

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

説明

🔎 Search Terms

autoAllocateChunkSize

🕗 Version & Regression Information
  • This is the behaviour in every version I tried, and I reviewed the FAQ for entries about readable, streams, byob, and autoallocatechunksize
⏯ Playground Link

https://www.typescriptlang.org/play/?ts=6.0.0-dev.20250806#code/HYUw7gBASiCGAmsBGAbEBlALgJzgWwAoBvAKAgkwE8AHEALggCIlLMQBnRgGjIlgFdMAewCCKFEIDGsNgGEAFv2ABrdAEsAXvQgBGAAwAmACw9y1fuIKShwHEPEhsASgily5a7ez202AHSSEuwgBE4A3LweNnYO-ixCSDAAjvwcmH647NQ28AR64bwAvjyFBUA

💻 Code
new ReadableStream({
  type: "bytes",
  autoAllocateChunkSize: 1024,
  pull(controller) {
    controller.close();
    controller.byobRequest.respond(0);
  },
});
🙁 Actual behavior

TypeScript says controller.byobRequest can be ReadableStreamBYOBRequest | null and errors when one tries to do .respond on it as null doesn't have that.

🙂 Expected behavior

TypeScript should say controller.byobRequest is ReadableStreamBYOBRequest because the autoAllocateChunkSize property is set. Meaning it can't be null according to https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream#autoallocatechunksize

Additional information about the issue

No response

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

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

はじめの一歩

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

調査の方向性

提供された TypeScript Playground のリンクから始め、autoAllocateChunkSizecontroller.byobRequest に関する ReadableStream コンストラクターの型定義を調べてください。nullability エラーを再現し、次に型定義が設定されたバイトストリームをどのように反映すべきかを判断し、例で nullability エラーなしに .respond(0) を受け入れられることを確認してください。

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

評価

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

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

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