Skip to content

How do I create an arktype equivalent to Record<string, CustomInterface[]> with 2.0.0-beta.0? #1058

Answered by ssalbdivad
BinToss asked this question in Q&A
Discussion options

You must be logged in to vote

I would recommend @maurice's answer with the slight adjustment that you don't need an intersection to specify an index signature alongside literal keys:

const iItemMetadata = type({ key1: "string", key2: "string", "[string]": "string" });

const myRecord = type({ "[string]": iItemMetadata.array() });

Additionally, there will be an option to invoke builtin generics like Record directly on arbitrary definitions in the next release, so you will be able to use something like:

ark.Record("string", iItemMetadata)

Working on better docs for this now, sorry for the confusion in the meantime!

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by BinToss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants