microsoft / microsoft/TypeScript

Option to report errors enabled by `useDefineForClassFields`, but still transpile using assignment semantics

Aperta
#56,298 4 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
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
⭐ 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
  1. What do you want to use this for?
  2. What shortcomings exist with current approaches?
  3. 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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. 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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.