diff --git a/deno/lib/__tests__/firstparty.test.ts b/deno/lib/__tests__/firstparty.test.ts index 66ed29bdb..5df8a71bd 100644 --- a/deno/lib/__tests__/firstparty.test.ts +++ b/deno/lib/__tests__/firstparty.test.ts @@ -78,6 +78,10 @@ test("first party switch", () => { break; case z.ZodFirstPartyTypeKind.ZodPipeline: break; + case z.ZodFirstPartyTypeKind.ZodSymbol: + break; + case z.ZodFirstPartyTypeKind.ZodReadonly: + break; default: util.assertNever(def); } diff --git a/deno/lib/__tests__/firstpartyschematypes.test.ts b/deno/lib/__tests__/firstpartyschematypes.test.ts new file mode 100644 index 000000000..d08818dbd --- /dev/null +++ b/deno/lib/__tests__/firstpartyschematypes.test.ts @@ -0,0 +1,21 @@ +// @ts-ignore TS6133 +import { expect } from "https://deno.land/x/expect@v0.2.6/mod.ts"; +const test = Deno.test; + +import { + ZodFirstPartySchemaTypes, + ZodFirstPartyTypeKind, +} from "../index.ts"; +import { util } from "../helpers/util.ts"; + +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.assertEqual(true); +}); diff --git a/deno/lib/types.ts b/deno/lib/types.ts index 23cbf1542..0b92fb593 100644 --- a/deno/lib/types.ts +++ b/deno/lib/types.ts @@ -4978,7 +4978,9 @@ export type ZodFirstPartySchemaTypes = | ZodCatch | ZodPromise | ZodBranded - | ZodPipeline; + | ZodPipeline + | ZodReadonly + | ZodSymbol; // requires TS 4.4+ abstract class Class { diff --git a/src/__tests__/firstparty.test.ts b/src/__tests__/firstparty.test.ts index bd5f6986d..2ad9cf88f 100644 --- a/src/__tests__/firstparty.test.ts +++ b/src/__tests__/firstparty.test.ts @@ -77,6 +77,10 @@ test("first party switch", () => { break; case z.ZodFirstPartyTypeKind.ZodPipeline: break; + case z.ZodFirstPartyTypeKind.ZodSymbol: + break; + case z.ZodFirstPartyTypeKind.ZodReadonly: + break; default: util.assertNever(def); } diff --git a/src/__tests__/firstpartyschematypes.test.ts b/src/__tests__/firstpartyschematypes.test.ts index 5c4cf7a38..79b2b9592 100644 --- a/src/__tests__/firstpartyschematypes.test.ts +++ b/src/__tests__/firstpartyschematypes.test.ts @@ -1,11 +1,11 @@ // @ts-ignore TS6133 import { test } from "@jest/globals"; -import { util } from "../helpers/util"; import { ZodFirstPartySchemaTypes, ZodFirstPartyTypeKind, } from ".."; +import { util } from "../helpers/util"; test("Identify missing [ZodFirstPartySchemaTypes]", () => { type ZodFirstPartySchemaForType = ZodFirstPartySchemaTypes extends infer Schema @@ -16,5 +16,5 @@ test("Identify missing [ZodFirstPartySchemaTypes]", () => { 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 + util.assertEqual(true); +});