microsoft / microsoft/TypeScript
Wrong error message for testing `void` with `??`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 Search Terms
nullish An expression of type 'void' cannot be tested for truthiness.
(there are many closed issues with these search term, but they are all from people confused by why this is an error in the first place)
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.3.3#code/CYUwxgNghgTiAEA3W8oC4kHsCWwDcAUAVPAPynwBmUEAziHkA
💻 Code
declare var a: void;
a ?? false;
🙁 Actual behavior
It reports "An expression of type 'void' cannot be tested for truthiness."
🙂 Expected behavior
The error message should not mention truthiness, since I'm not testing for truthiness. nullishness? :P
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 riproducendo il problema nel TypeScript Playground collegato usando l'esempio fornito con void e ??. Traccia la diagnostica che produce “An expression of type 'void' cannot be tested for truthiness”; il lavoro è completato quando il messaggio non fa più riferimento a truthiness nella segnalazione di questo errore di nullishness.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100