microsoft / microsoft/TypeScript
`controller.byobRequest` type incorrectly says value is possibly null while `autoAllocateChunkSize` is present.
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 132
Mô tả
### 🔎 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
```ts
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_
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với liên kết TypeScript Playground được cung cấp và kiểm tra kiểu của hàm khởi tạo ReadableStream liên quan đến `autoAllocateChunkSize` và `controller.byobRequest`. Tái hiện lỗi khả năng nhận giá trị null, sau đó xác định kiểu nên phản ánh luồng byte đã cấu hình như thế nào và xác minh rằng ví dụ chấp nhận `.respond(0)` mà không có lỗi giá trị null.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- compilers
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100