Is there a recommended way to create a Record using a type as a key?
None of these seem to work:
2 Replies
I get the error
ParseError: Index keys "CAR", "DEV", "ECO", "ENDO", "GEN", "IMM", "IRR", "NEU", "ORG", "REP", "RES" should be specified as named props.
Yeah unfortunately this was a mistake in how the parser was implemented to ensure named properties are normalized in their representation:
https://github.com/arktypeio/arktype/issues/952
The easiest thing to do for now would probably just be to define that initial set of keys as a tuple, then you can map it with
Object.fromEntries
to build the type you want.GitHub
Allow index node to be parsed from enumerable keys · Issue #952 · a...
Currently, an index signature including a literal key like "a" is an error due to some limitations of how the parser is implemented. There is a normalizeIndexKey function, but it is not u...