diff --git a/src/__tests__/firstpartyschematypes.test.ts b/src/__tests__/firstpartyschematypes.test.ts new file mode 100644 index 000000000..5c4cf7a38 --- /dev/null +++ b/src/__tests__/firstpartyschematypes.test.ts @@ -0,0 +1,20 @@ +// @ts-ignore TS6133 +import { test } from "@jest/globals"; +import { util } from "../helpers/util"; + +import { + ZodFirstPartySchemaTypes, + ZodFirstPartyTypeKind, +} from ".."; + +test("Identify missing [ZodFirstPartySchemaTypes]", () => { + type ZodFirstPartySchemaForType = ZodFirstPartySchemaTypes extends infer Schema + ? Schema extends { _def: { typeName: T } } + ? Schema + : never + : never; + type ZodMappedTypes = { [key in ZodFirstPartyTypeKind]: ZodFirstPartySchemaForType }; + type ZodFirstPartySchemaTypesMissingFromUnion = keyof { [key in keyof ZodMappedTypes as ZodMappedTypes[key] extends { _def: never } ? key : never]: unknown }; + + util.assertNever({} as ZodFirstPartySchemaTypesMissingFromUnion); +}); \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index c60be474e..23e0196fa 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4972,7 +4972,9 @@ export type ZodFirstPartySchemaTypes = | ZodCatch | ZodPromise | ZodBranded - | ZodPipeline; + | ZodPipeline + | ZodReadonly + | ZodSymbol; // requires TS 4.4+ abstract class Class {