microsoft / microsoft/TypeScript

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

Aperta
#62,224 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

🔎 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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con il link fornito a TypeScript Playground ed esamina la tipizzazione del costruttore di ReadableStream relativa a autoAllocateChunkSize e controller.byobRequest. Riproduci l’errore di nullabilità, quindi determina come la tipizzazione dovrebbe riflettere il flusso di byte configurato e verifica che l’esempio accetti .respond(0) senza un errore di nullabilità.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.