microsoft / microsoft/TypeScript
Automatic Brace Insertion (ABI) is undesirable
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
TypeScript Version: 3.7-beta
Search Terms: automatic brace insertion ABI syntax error
Code:
function a() {
"Automatic Brace Insertion! (ABI)";
Expected behavior:
The input is syntactically invalid, so emit should fail regardless of the state of noEmitOnError. Other forms of un-parsable input already do this, e.g. function a(
Actual behavior:
A closing brace is inserted in the emitted JS code.
function a() {
"Automatic Brace Insertion! (ABI)";
}
This means that users who are not using noEmitOnError are silently having invalid code transformed into valid code. I can confirm this actually happened to someone shipping something to production.
Playground Link: ABI Playground Link
Related Issues: https://github.com/microsoft/TypeScript/issues/34870 , https://github.com/microsoft/TypeScript/issues/34871 , Lazy Twitter report
I would suggest this bug deserves to be fixed based on Design Goal 7 (Preserve runtime behavior of all JavaScript code) and Design Non-Goal 7 (Introduce behaviour that is likely to surprise users).
Tagline: If the braces don't fit, you must not emit.
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 con l’ABI Playground Link e l’input TypeScript minimo mostrato nell’issue, quindi confronta il suo comportamento di emit con l’esempio collegato di una funzione non terminata. Traccia la gestione di questo input malformato da parte del compilatore e verifica che emit non aggiunga una parentesi graffa di chiusura e non produca JavaScript eseguibile.
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
- Abbastanza chiara
- Idoneità per principianti
- 35/100