You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've found myself using const enums with (figuratively) namespaced property names. There is a lot of duplication when nesting though, and I keep finding myself wishing that the TypeScript compiler could recognise that its compile-time-constant requirement for such values was in fact satisfiable with respect to expressions composed of identifiers that are entirely compile-time resolvable.
Code
constenumRoot{foo='foo';}constenumNested{bar=Root.foo+':bar',baz=`${A.foo}:baz`}// const strings could be included:constroot='root';constenumRoot{foo=root+':foo';}// or another idea:constenumNestedextendsRoot.foo{bar=':bar'// => 'root:foo:bar'}
I'm not sure how straightforward this would be to implement, but it does seem to me that if an expression can be resolved at compile time, it should be valid in a const enum type. If the compiler is able to resolve compile-time expressions at all, I imagine that some of the same code might also overlap with other issues relating to use of const symbols in interfaces.
The text was updated successfully, but these errors were encountered:
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 2.5.2
I've found myself using const enums with (figuratively) namespaced property names. There is a lot of duplication when nesting though, and I keep finding myself wishing that the TypeScript compiler could recognise that its compile-time-constant requirement for such values was in fact satisfiable with respect to expressions composed of identifiers that are entirely compile-time resolvable.
Code
I'm not sure how straightforward this would be to implement, but it does seem to me that if an expression can be resolved at compile time, it should be valid in a const enum type. If the compiler is able to resolve compile-time expressions at all, I imagine that some of the same code might also overlap with other issues relating to use of
const
symbols in interfaces.The text was updated successfully, but these errors were encountered: