Consider following pseudo type signature for TypeScript:
import { z, ZodObject, ZodRawShape } from 'zod';
export type DefinitionObject<T extends ZodRawShape> = {
validator: ZodObject<T>;
htmlFn: (value: z.infer<typeof validator> & { locale?: string; }) => JSX.Element;
};
The type of htmlFn
key depends on type of validator
key via typeof validator
. But of course, TypeScript errors with:
Cannot find name 'validator'.ts (2304)
Parameter 'value' of exported function has or is using private name 'validator'.ts (4078)
So, I need something like this.validator
inside the type signature context. How can I achieve this?