MCPcopy Index your code
hub / github.com/monkeytypegame/monkeytype / getOptions

Function getOptions

frontend/src/ts/utils/zod.ts:13–28  ·  view source on GitHub ↗
(
  schema: T,
)

Source from the content-addressed store, hash-verified

11} from "zod";
12
13export function getOptions<T extends ZodSchema>(
14 schema: T,
15): undefined | z.infer<T>[] {
16 if (schema instanceof z.ZodLiteral) {
17 return [schema.value] as z.infer<T>[];
18 } else if (schema instanceof z.ZodEnum) {
19 return schema.options as z.infer<T>[];
20 } else if (schema instanceof z.ZodBoolean) {
21 return [false, true] as z.infer<T>[];
22 } else if (schema instanceof z.ZodUnion) {
23 return (schema.options as ZodSchema[])
24 .flatMap(getOptions)
25 .filter((it) => it !== undefined) as z.infer<T>[];
26 }
27 return undefined;
28}
29
30export function getZodType(schema: ZodTypeAny): ZodFirstPartyTypeKind {
31 // oxlint-disable-next-line typescript/no-unsafe-assignment typescript/no-unsafe-member-access

Callers 5

autoInputsFunction · 0.90
CustomBackgroundFunction · 0.90
PaceCaretFunction · 0.90
FontFamilyFunction · 0.90
buildCommandWithSubgroupFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected