microsoft / microsoft/TypeScript
Uncalled function checks don't work with negation
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Bug Report
🔎 Search Terms
uncalled function checks, negation
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
Playground link with relevant code
💻 Code
declare function isFoo(): boolean;
declare const isUndefinedFoo: (() => boolean) | undefined;
if (isFoo) {
// uncalled function checks already work well here
}
if (!isFoo) {
// uncalled function checks should cover this case too
}
if (!isUndefinedFoo) {
// this case should not be covered
}
🙁 Actual behavior
Uncalled function checks do not work with the ! operator.
🙂 Expected behavior
Unless a function may be undefined it would be very helpful to check whether it is called when it is used with the ! operator.
I created this issue to separate a part of the implementation of #42835 resulting from issue #35584. This specific issue was inspired by https://github.com/microsoft/TypeScript/issues/35584#issuecomment-769401594.
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
Riproduci il comportamento nel TypeScript Playground collegato, confrontando i controlli positivi e negati per isFoo e isUndefinedFoo. Leggi l’implementazione di uncalled-function-check associata a #42835 e la discussione in #35584; il lavoro è completo quando la negazione segnala le funzioni non chiamate sicuramente definite senza segnalare erroneamente le funzioni potenzialmente non definite.
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à
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 38/100