#Error using zod based type in defineProps<>()

3 messages · Page 1 of 1 (latest)

onyx garden
#

When exporting type using z.infer<> of zod schema I have an error in defineProps<>() place.
Pre-transform error: [@vue/compiler-sfc] Unresolvable type reference or unsupported built-in utility type

PS: when using type without schema it works

Code:

types.ts
....
const CustomerSchema = z.object({ firstName: z.string() }) // dummy schema
export type Customer = z.infer<typeof CustomerSchema>

....
<script setup lang="ts">
import type { Customer } from '/types'

const props = defineProps<Customer>()
...
flat wigeon
#

Hi, i have a working example for you. 🙂