Skip to content

Commit

Permalink
Test ZodFirstPartySchemaTypes in sync with ZodFirstPartyTypeKind
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsMud committed Feb 16, 2024
1 parent 2762d1f commit d22f342
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/__tests__/firstpartyschematypes.test.ts
Original file line number Diff line number Diff line change
@@ -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<T extends ZodFirstPartyTypeKind> = ZodFirstPartySchemaTypes extends infer Schema
? Schema extends { _def: { typeName: T } }
? Schema
: never
: never;
type ZodMappedTypes = { [key in ZodFirstPartyTypeKind]: ZodFirstPartySchemaForType<key> };
type ZodFirstPartySchemaTypesMissingFromUnion = keyof { [key in keyof ZodMappedTypes as ZodMappedTypes[key] extends { _def: never } ? key : never]: unknown };

util.assertNever({} as ZodFirstPartySchemaTypesMissingFromUnion);
});

0 comments on commit d22f342

Please sign in to comment.