Indexed Access Types
Hello, is it possible to recreate the
SizeValues
type below in arktype? 5 Replies
One way to do it:
But I wouldn't see the use case for this particular type...
What are you planning to do with it?
not possible yet: https://github.com/arktypeio/arktype/issues/831
GitHub
Index access expressions · Issue #831 · arktypeio/arktype
Would allow expressions like the following: const types = scope({ base: { foo: "true", bar: "false", }, // 1:1 with TS foo: "base['foo']", // Allow more conven...
Thank you! Good question... I've been looking at this for so long I can't remember 😂 Let me give a more detailed example: I'm trying to create a type to be used to validate the payload in a search request. I've landed on this as the implementation
I was wondering if there was a cleaner/preferred way to pick out the
value
prop from the size
array with arktype, rather than creating a new array via the map.It seems clean to me. You have the config in a centralized object. Other ways would probably include splitting it up into multiple smaller types and then connecting them
If you're going to reuse the status and sizes in different places, you could create a type from them and then nest it somewhere
Nice, thank you for the help!