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
// We can quickly address your report if:// - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!// - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.// - The incorrectness of the behavior is readily apparent from reading the sample.// Reports are slower to investigate if:// - We have to pare too much extraneous code.// - We have to clone a large repo and validate that the problem isn't elsewhere.// - The sample is confusing or doesn't clearly demonstrate what's wrong.exportenumE{'a-b-c'='abc.com','def'='def.com',}exporttypeM={[einE]?: 'literal';}constm0: M={[E['a-b-c']]: 'literal',// error here[E.def]: 'literal'// no error};export{m0};
π Actual behavior
When use Enum['value'] as the key of a mapping, values assigned to string literal types are not correctly recognized.
The string literal is always lifted as string type and there is an error Type of computed property's value is 'string', which is not assignable to type '"literal"'.
However, if Enum.value form is used as the mapping key, everything works fine.
π Expected behavior
The aforementioned error should not occur.
Type check should be consistent when using Enum['value'] and Enum.value.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
π Search Terms
map enum key literal value
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
When use
Enum['value']
as the key of a mapping, values assigned to string literal types are not correctly recognized.The string literal is always lifted as string type and there is an error
Type of computed property's value is 'string', which is not assignable to type '"literal"'.
However, if
Enum.value
form is used as the mapping key, everything works fine.π Expected behavior
The aforementioned error should not occur.
Type check should be consistent when using
Enum['value']
andEnum.value
.The text was updated successfully, but these errors were encountered: