microsoft / microsoft/TypeScript
`isolatedModules` does not generate the same code
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
isolatedModules
const enum
inlining
generated code
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
const enum NotSoAwesomeConstEnum {
SomeValue,
AnotherOne
}
function dosomething(state: NotSoAwesomeConstEnum): void {
switch (state) {
case NotSoAwesomeConstEnum.SomeValue:
console.log('SomeValue');
break;
case NotSoAwesomeConstEnum.AnotherOne:
console.log('AnotherOne');
break;
}
}
🙁 Actual behavior
The emitted code is not the same when using isolatedModules.
🙂 Expected behavior
The emitted code should be the same when using isolatedModules as it is described as nothing else but a check
Setting the isolatedModules flag tells TypeScript to warn you if you write certain code that can’t be correctly interpreted by a single-file transpilation process.
const enum values should be inlined even when using this flag. (Or an error should be emitted).
Additional information about the issue
From the documentation:
It does not change the behavior of your code, or otherwise change the behavior of TypeScript’s checking and emitting process.
Which is not true, at least for const enum as this prevents inlining.
See the playground link and https://github.com/microsoft/TypeScript/issues/16671#issuecomment-1686858424
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 il TypeScript Playground collegato e confronta il codice emesso con e senza isolatedModules per l’esempio di const enum. Segui il percorso del compilatore responsabile della gestione di const enum e determina se i valori debbano essere inseriti inline o se debba essere segnalato un errore; il lavoro è completato quando l’output corrisponde o è presente una diagnosi chiara.
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
- 45/100