microsoft / microsoft/TypeScript
`isolatedModules` does not generate the same code
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
🔎 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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con el TypeScript Playground enlazado y compara el código emitido con y sin isolatedModules para el ejemplo de const enum. Sigue la ruta del compilador responsable del manejo de const enum y determina si los valores deben insertarse inline o si debe notificarse un error; se considera terminado cuando la salida coincide o existe un diagnóstico claro.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100