-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add types to
ZodFirstPartySchemaTypes
(#3247)
* Add `ZodSymbol` and `ZodReadonly` to `ZodFirstPartySchemaTypes` * Test `ZodFirstPartySchemaTypes` in sync with `ZodFirstPartyTypeKind`
- Loading branch information
1 parent
7fa37bb
commit cb94d30
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters