Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zod - Property 'infer' does not exist on type 'typeof import(.../node_modules/zod/lib/external)

I got the Typescript error:

Property 'infer' does not exist on type 'typeof import(.../node_modules/zod/lib/external)

on the code: const CampaignForm = z.infer<typeof CampaignSchema>;

Looking at the docs and node_modules the property is there.

like image 876
Itay Tur Avatar asked Jan 20 '26 08:01

Itay Tur


1 Answers

The issue was using const instead of type.

Expected: type CampaignForm = z.infer<typeof CampaignSchema>;

Actual: const CampaignForm = z.infer<typeof CampaignSchema>;

The error is misleading.

like image 68
Itay Tur Avatar answered Jan 22 '26 23:01

Itay Tur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!