cross posting from #typescript
noob question!
how would i express this type using arktype syntax?
i tried:
but it doesn't work on
v2.0.0-rc.30
.7 Replies
I would just chain
.array()
instead of using the args syntax:
What you wrote should work but it seems like a TypeScript bug
It does work if you split it up though so some TS issue related to the inner inference:
Or this if you prefer I suppose:
thanks for the quick response!
hmm, i don't know if splitting it up is an option. let me try
.array()
i'm doing this programmatically, so i need to make sure i'm able to detect when to use which syntax, in which context
will .array()
work in all cases?You're generating ArkType definitions?
yeah
Yeah
.array()
should be the most reliable nothing can really go wrongcool, thank youuu you're the best
As long as you avoid nested
type
calls or nested tuple expressions you should be pretty safe in general though
Stuff like your original definition generally works but TS has weird rules around inference that can sometimes get in the way. As long as you don't have anything like that or nested tuple expressions for a similar reason all roads should lead to Rome or whatever haha