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

ts/no-redeclare error when using zod lib #648

Closed
gabrielrufino opened this issue Jan 2, 2025 · 1 comment
Closed

ts/no-redeclare error when using zod lib #648

gabrielrufino opened this issue Jan 2, 2025 · 1 comment

Comments

@gabrielrufino
Copy link

For this code:

import z from 'zod'

export const CreateProductDto = z.object({
  name: z.string(),
  price: z.number().nonnegative().finite().safe(),
})

export type CreateProductDto = z.infer<typeof CreateProductDto>

I got this error:

  8:13  error  'CreateProductDto' is already defined  ts/no-redeclare

✖ 1 problem (1 error, 0 warnings)

What do you guys think is the correct way to solve this problem? Should I disable this rule?

@antfu
Copy link
Owner

antfu commented Jan 2, 2025

To me, this looks like it is working as expected. Even if they are in different space (value space / type space), it's still better to avoid naming different things as the same name. If you explicitly wants that feel free to disable it yourself. It's out of discussion for this config.

@antfu antfu closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
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

2 participants