Referencing self
Hello, I have a type A
How can I reference itself in
arrayOf
? A
doesn't seem to work.3 Replies
So first I'd recommend upgrading to
2.0.0-dev.10
which was just released.
In the next ~week there will be a this
keyword that allows you to reference the current type:
Until then, you will need to use a scope:
The other nice thing about a scope is that you can then reuse someObj
in other string definitions as well in the same scope, so it makes your types composable in expressions.Thank you!
Also a couple of the big changes while migrating:
Helper methods like union and intersection are now chained directly off a type instance like
type({a: "string"}).or({b: "number"})
Instead of a discriminated union like { problems, data}
or {out, errors}
, the default type invocation now returns YourOutput | ArkErrors
. You can still check if your result is valid with a simple expression like:
More docs coming soon!