microsoft / microsoft/TypeScript
Option to report errors enabled by `useDefineForClassFields`, but still transpile using assignment semantics
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
"useDefineForClassFields", "class fields errors"
✅ 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
Add an option to have TSC generate the same errors it currently generates for useDefineForClassFields = True, but while still continuing to transpile fields using the non-spec-compliant assignment semantics.
📃 Motivating Example
We must run TS with useDefineForClassFields = false, because we find the output code size of define semantics unacceptably large.
We want to be certain that our code continues to behave the same way when we are able to ship this code to environments that understand class fields without transpilation.
We want to eliminate from our code base all cases where field definitions behave differently between the 2 semantics, and then prevent them from ever returning.
To do this, it would be extremely helpful if TSC could report errors for code that would behave differently with define semantics, but also continue transpiling with assign semantics.
💻 Use Cases
- What do you want to use this for?
- What shortcomings exist with current approaches?
- What workarounds are you using in the meantime?
For 1:
see the Motivating Example.
For 2 & 3:
The only workaround I know of is to run TSC twice with different options, once for the output we want and once for the errors we want. This is prohibitively expensive to do at scale.
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’opzione del compilatore useDefineForClassFields esistente e le due modalità di emissione dei campi di classe descritte nell’issue. Confronta i diagnostici prodotti con la semantica di definizione con l’output con semantica di assegnazione, quindi individua come un’opzione di controllo separata potrebbe preservare tali diagnostici senza modificare il JavaScript emesso; non sono indicati file o test, quindi per completare il lavoro sarebbe necessario aggiungere la copertura per entrambe le modalità.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, 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
- 35/100