You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a beginner at arktype and i'm rather confused by how getting default values works in an idiomatic way. In zod there would be a meta field where you can get the default values that you set from the schema declaration, but in arktype it's typed as unknown. As for an example, i have a basic object with defaults and i want to declare some variables that is just the default value of each field. The code below works but i have to cast it because the type is originally ArkErrors | T. Is there a cleaner way to get default field values in an object ?
import{type}from"arktype"constThing=type({pageIndex: "number = 1",pageSize: "number = 15","query?": "string",});// i just want 1 hereconstdefaultPageIndex=(Thing({})asunknownastypeofThing.infer).pageIndex// i just want 15 hereconstdefaultPageSize=(Thing({})asunknownastypeofThing.infer).pageSize
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm a beginner at arktype and i'm rather confused by how getting default values works in an idiomatic way. In zod there would be a meta field where you can get the default values that you set from the schema declaration, but in arktype it's typed as
unknown
. As for an example, i have a basic object with defaults and i want to declare some variables that is just the default value of each field. The code below works but i have to cast it because the type is originallyArkErrors | T
. Is there a cleaner way to get default field values in an object ?Beta Was this translation helpful? Give feedback.
All reactions