microsoft / microsoft/TypeScript

namespace containing only 'const enum' can be used as value -> causing runtime error

Aperta
#28,590 0 commenti 1 reazione 1 assegnatario Vedi su GitHub

@weswigham ci sta già lavorando.

Dal 8/12/2018.

Bug Domain: enum
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

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:

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.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.