Skip to content

Allow to disable getUniqueComponentName transform #2609

@seanwu1105

Description

@seanwu1105

Description

Currently, if two generated components have the same identifier name, the second one will be suffixed with an auto-incremental integer started from 2. This is usually the desired behavior. However, it limits the use case where the identifier of a type and a value (e.g. const) can share the same name. For example,

const MyModel = z.object({id: z.string()})
type MyModel = z.infer<typeof MyModel>

This is a valid TypeScript code but it's not achievable with existing Zod plugin since getUniqueComponentName is always called after the name is generated even when the name is specified as a getter function. To achieve the goal and make the API more flexible, we can add an option to skip getUniqueComponentName.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Something isn't workingfeature 🚀New feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions