arktypea
arktype15mo ago
mihajm

Is there a way to morph an optional value back to a required one?

the example bellow always returns a number, but is typed as {PORT?: number | undefined}
const schema = type({
  PORT: ['string?', '=>', (v?: string) => parseInt(v ?? '3000')]
})
image.png
Was this page helpful?