microsoft / microsoft/TypeScript
`controller.byobRequest` type incorrectly says value is possibly null while `autoAllocateChunkSize` is present.
Nessuno ha ancora preso questa issue.
- 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
💻 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- 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