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

JSDoc hints are lost after using .extend #3437

Comments

@todor-a
Copy link

todor-a commented Apr 24, 2024

Once you use .extend, any JSDoc hints are lost.

import { z } from 'zod';

const v1 = z.object({
    /** this works */
    userId: z.string(),
});

const v2 = z.object({
    /** this doesn't */
    itemId: z.string(),
}).extend(v1.shape);

const instance1: z.infer<typeof v1> = {
    userId: '2' // has hint on hover
}

const instance2: z.infer<typeof v2> = {
    itemId: '1',
    userId: '2'
}

Playground - https://tsplay.dev/w2oKzN

@colinhacks
Copy link
Owner

In my experiments, this isn't a solvable problem, but perhaps others can succeed where I've failed.

@samchungy
Copy link
Contributor

This works in 3.22.4

@colinhacks
Copy link
Owner

Merged and landed in v3.23.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment