-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const enum
inside a namespace makes it treated as a value
#17372
Comments
We'll still need to block this under |
More generally, then, we believe const enum Foo {A, B}
declare const Foo: number; Is allowable? I think I understand why this isn't actually a bug - I think it's intended behavior: A |
Pretty much the same with #16804, which is a variation on the same issue. |
I just ran into this issue today. Here's my vote for "I think this is a bug that should be fixed", although I see the complication. At compile time, a const enum's value is a "value-meaning symbol" that needs to follow all the same rules as other "value-meaning symbols", but at runtime the enum (and its values) doesn't exist at all. Seems like a special edge case that, when not using --preserveConstEnums, a const enum's value should not be considered a "value" for the purpose of determining whether a namespace "contains values". But for all other purposes, a const enum's value should still be treated like a "value-meaning symbol". |
I believe I'm facing the same issue here; I just wanted to add another example. export function createElement() {
// some implementation...
}
export const h = createElement;
// This works
export namespace createElement {
export import JSX = JSXTypes;
}
// This does not work.
export declare namespace h {
export import JSX = JSXTypes;
} The reason this is needed is because JSX namespace is picked up from createElement (or h) when jsxFactory = "createElement" (or "h"). |
TypeScript Version: nightly (2.5.0-dev.20170719)
Code
Expected behavior:
No error.
N
does not contain any values, so it should be OK to merge it with a value.Actual behavior:
The text was updated successfully, but these errors were encountered: