A
arktype12mo ago
Micha

Are you recommending to create first ArkType types and derive from their TS types or vice versa?

Are you recommending to create first ArkType types and derive from their TS types or vice versa?
1 Reply
ssalbdivad
ssalbdivad12mo ago
Ideally TS should be inferred from ArkType like this:
const user = type({
name: "string",
age: "number"
})

type User = typeof user.infer
const user = type({
name: "string",
age: "number"
})

type User = typeof user.infer
If you need to do the reverse, there are ways but it's not ideal since it involves duplication. Usually you'd want that if you have to adhere to an external set of TS types you don't have control over.

Did you find this page helpful?