Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use z.infer. Property 'infer' does not exist on type #3099

Closed
hitfm00 opened this issue Jan 1, 2024 · 1 comment
Closed

Cannot use z.infer. Property 'infer' does not exist on type #3099

hitfm00 opened this issue Jan 1, 2024 · 1 comment

Comments

@hitfm00
Copy link

hitfm00 commented Jan 1, 2024

Version zod: ^3.22.4
When I try to use z.infer<typeof SomeSchema> I don't have a infer in z

All code:

import  z  from "zod";

export const ProductsSchema = z.object({
  title: z.string().max(255),
  description: z.string().max(255),
  price: z.number(),
});


export const ProductsSchemaType = z.infer<typeof ProductsSchema>;

And have this error when trying to use infer:
Property 'infer' does not exist on type 'typeof import("/project/node_modules/zod/index")'.

  • My autocomplete doesn't see this infer when I type dot after z as if he doesn't exist at all
@hitfm00
Copy link
Author

hitfm00 commented Jan 2, 2024

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.

@hitfm00 hitfm00 closed this as completed Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant