microsoft / microsoft/TypeScript
`controller.byobRequest` type incorrectly says value is possibly null while `autoAllocateChunkSize` is present.
未关闭
还没有人认领这个 Issue。
Awaiting More Feedback
Suggestion
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 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
💻 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从提供的 TypeScript Playground 链接开始,检查与 autoAllocateChunkSize 和 controller.byobRequest 相关的 ReadableStream 构造函数类型。复现可空性错误,然后确定类型应如何反映已配置的字节流,并验证该示例可以接受 .respond(0) 而不会出现可空性错误。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100