Use native ts type
I was wondering if I could use an already created type:
inside an arktype type declaration:
I would go on and create an arktype literal as suggested in the docs, but this type is being declared from another object:
And I want it to be tighly coupled with that object
4 Replies
Iirc
.as
can be used for using a pre-existing typeIf you have them in an object I'd do what Dimava suggests so there's a single source of truth.
You can also do
type.enumerated(...keys)
if you prefer. You'll just have to make sure you cast your keys list since TS won't narrow it by defaultRight I was doing that but and by default TS considered it string, doing what Dimava suggested makes this union of string literals that I wanted, thanks!