zod
zod copied to clipboard
JSDoc hints are lost after using `.extend`
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
In my experiments, this isn't a solvable problem, but perhaps others can succeed where I've failed.
This works in 3.22.4
Merged and landed in v3.23.7