Creating array from another object
I'm new at arktype, just been trying to do
UserSchema[].
I haven't seen anything on the docs, so how am I supposed to do arrays with types?
What I have right now:
6 Replies
I actually moved to this Sorry, I didn't like the magic string that will eventually turn to this anyways
participants: UserSchema.array()thx!
do people normally do it with the string notation instead of this?
i only started using arktype yesterday so idk 😆 but im liking the string notation, it matches typescript type syntax, is incredibly well typed, compat, and its vscode extension is a big plus
there's not really a way to embed type-safe objects in strings like this. maybe if TS eventually supports improved types for tagged template literals.
if you don't like the string syntax anyways then yeah just use chaining here for sure.
strings for cases like
string | null are more canonical for the reasons @Apteryx mentions but there are multiple options for a reasonI'm not using vscode, but even if it's highlighted it'd be... weird? dunno how to say it
I understand it though