microsoft / microsoft/TypeScript
Add a flag to error when an uninitialized function is called
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
uninitialized function - uninitialized - uninitialized function call
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- 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 isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
This is a request to add a new configuration flag that makes typescript error when an uninitialized function is called within the same scope
This is a comment made by @RyanCavanaugh on a similar topic (using an uninitialized variable) for why an error is not thrown by typescript in the case of using an uninitialized variable (not calling a function)
There are more comments on this topic
But the same argument of why function parameters assignment is contra-variant applies to why throw an error when an uninitialized function is called. Typescript doesn't know if it will surely error but it prevents it anyway
📃 Motivating Example
The below is a case of a runtime error thrown by calling an uninitialized variable which typescript didn't prevent
💻 Use Cases
- What do you want to use this for? Preventing runtime errors
- What shortcomings exist with current approaches? none
- What workarounds are you using in the meantime?
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 esaminando l’esempio motivante di TypeScript Playground e la discussione collegata nell’issue #56827 sulle variabili non inizializzate. Definisci che cosa deve diagnosticare il nuovo flag di configurazione per le chiamate a funzioni non inizializzate nello stesso ambito e considera i vincoli indicati: non deve modificare il JavaScript emesso né il comportamento esistente in fase di esecuzione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100