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
Expected behavior: as described here: #2491 (comment), this should be a work around to map an enum to object keys. We were using it successfully until v3.5.3 (I just installed v3.5.3 to double check and no error).
Actual behavior: Typescript complains: Object literal may only specify known properties, and ''image'' does not exist in type '{ [x: number]: string; }'.
Looks similar to this: #2491 (comment)
If you remove the as any on the enum should work. I don't known the reason to use it. Typescript supports enums with string values since version 2.4. Full code:
I'm not sure why the any assertion is used in your enum, but it causes the enum to be considered a numeric enum which is in turn affected by the linked PR.
Prior to #31784, the type of layoutElementTypesMap was the empty object type and not subject to excess property checking.
Perfect thanks @jack-williams and @j-oliveras, this does indeed fix it.
This code is legacy and written before I worked on it and I wasn't sure why too it was there, but legacy being legacy, I tend to leave things that look weird but work. Good cleanup then.
TypeScript Version: 3.6.2
Search Terms: Mapped Types, MappedTypes, MappedType
Code
Expected behavior: as described here: #2491 (comment), this should be a work around to map an enum to object keys. We were using it successfully until v3.5.3 (I just installed v3.5.3 to double check and no error).
Actual behavior: Typescript complains:
Object literal may only specify known properties, and ''image'' does not exist in type '{ [x: number]: string; }'.
Looks similar to this: #2491 (comment)
Playground Link:
Related Issues: #2491
The text was updated successfully, but these errors were encountered: