string literal type defined via a mapped type is sometimes erroneously interpreted as simply string
#16553
Labels
Duplicate
An existing issue was already created
A "direct" string literal type defined using
type Foo = "A";
behaves properly in more places than an apparently-equivalent "indirect" string literal type defined using mapped types.TypeScript Version: 2.3.4
Code
I discovered this issue while using https://github.com./dphilipson/typescript-string-enums, and as such, have inlined the relevant part of the library into the top of the example.
Expected behavior:
Both definitions of
MyEnum
are equal and interchangeable.Actual behavior:
The "indirect" type erroneously fails to compile in one of the two functions.
The text was updated successfully, but these errors were encountered: