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
[key in Foo]: string (for the first example) resolves to [n: number]: string - a mapped type over a non-union doesn't produce an object with defined properties, and Foo is only a union (rather than a subtype of number) when its members are initialized with constant literals. Neither of those behaviors are really negotiable, even if their combination in this instance is a bit surprising.
So is the stance that we should create an auxiliary store for any flag variables and then pass (from the enum) through them instead? This feels too roundabout and cumbersome to be a solution though.
TypeScript Version: 4.0.0-dev.20200726
Search Terms: enum index pattern-matching
Code
Expected behavior:
The program fails to compile because property
'4'
is missing inmyFoos
As a counter example, this fails to compile properly:
because
Foo.buddy
is missing inmyFoos
.Actual behavior:
Succesfully compiles and outputs
{ '1': 'hello', '2': 'world' }
even though one of the enum fields doesn't exist.Playground Link: Link
Related Issues:
The text was updated successfully, but these errors were encountered: