microsoft / microsoft/TypeScript
namespace containing only 'const enum' can be used as value -> causing runtime error
@weswigham arbeitet bereits daran.
Seit 08.12.2018.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
TypeScript Version: 3.2.0-dev.20181110
Search Terms: namespace const enum
Code
namespace foo {
export const enum Foo {}
}
console.log(foo);
Expected behavior:
Error when using foo as a value. It's already an error to use a namespace that contains only types (and is therefore not emitted) as value.
The Symbol of the ModuleDeclaration actually contains constEnumOnlyModule: true, it just needs to be checked.
Actual behavior:
Doesn't emit the namespace in transpiled output, but it's still referenced by console.log(foo);
Playground Link: https://agentcooper.github.io/typescript-play/#code/HYQwtgpgzgDiDGEAEAzA9mpBvAUE-SEAHjGgE4AuS8awUVEwArmEgGIbYC+OPNdaADYQAdILQBzABTo0ASgDcQA
Related Issues:
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.