microsoft / microsoft/TypeScript
Extend "no comparison with NaN" check to cover "Number.NaN"
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Suggestion
🔍 Search Terms
x === Number.NaN
disallow comparing with Number.NaN
✅ Viability Checklist
My suggestion meets these guidelines:
- [?] This wouldn't be a breaking change in existing TypeScript/JavaScript code - this would break code containing the error
- ✅ This wouldn't change the runtime behavior of existing JavaScript code
- ✅ This could be implemented without emitting different JS based on the types of the expressions
- ✅ This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- ✅ This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
Extend check added for https://github.com/microsoft/TypeScript/issues/49962 to include Number.NaN in addition to global NaN.
📃 Motivating Example
function useVersionNumber(value: string) {
let versionNumber = Number(value);
if (versionNumber === Number.NaN) {
return;
}
console.log(versionNumber + 1);
}
💻 Use Cases
Catching a developer error (incorrect NaN handling).
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
Leggi il controllo esistente referenziato nell’issue #49962 e individua la sua implementazione e i relativi test nel repository TypeScript. Estendi lo stesso comportamento alla forma Number.NaN, quindi verifica che venga segnalato il confronto alla base della richiesta, mentre l’output JavaScript a runtime rimane invariato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100