diff --git a/src/core/validateGeneratedTypes.test.ts b/src/core/validateGeneratedTypes.test.ts index 3d8925da..04a4d0ab 100644 --- a/src/core/validateGeneratedTypes.test.ts +++ b/src/core/validateGeneratedTypes.test.ts @@ -47,6 +47,56 @@ describe("validateGeneratedTypes", () => { expect(errors).toEqual([]); }); + it("should return no error if we use a non-optional any", () => { + const sourceTypes = { + sourceText: ` + export interface Citizen { + villain: any; + }; + `, + relativePath: "source.ts", + }; + + const zodSchemas = { + sourceText: `// Generated by ts-to-zod + import { z } from "zod"; + export const citizenSchema = z.object({ + villain: z.any() + }); + `, + relativePath: "source.zod.ts", + }; + + const integrationTests = { + sourceText: `// Generated by ts-to-zod + import { z } from "zod"; + + import * as spec from "./${sourceTypes.relativePath.slice(0, -3)}"; + import * as generated from "./${zodSchemas.relativePath.slice(0, -3)}"; + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + function expectType(_: T) { + /* noop */ + } + + export type CitizenInferredType = z.infer; + + expectType({} as spec.Citizen); + expectType({} as CitizenInferredType); + `, + relativePath: "source.integration.ts", + }; + + const errors = validateGeneratedTypes({ + sourceTypes, + zodSchemas, + integrationTests, + skipParseJSDoc: false, + }); + + expect(errors).toEqual([]); + }); + it("should return an error if the types doesn't match", () => { const sourceTypes = { sourceText: `