diff --git a/lib/types/json-schema.ts b/lib/types/json-schema.ts index be68547ff..20fa4b7f8 100644 --- a/lib/types/json-schema.ts +++ b/lib/types/json-schema.ts @@ -24,6 +24,30 @@ interface StringKeywords { } export type JSONSchemaType = ( + | // these two unions allow arbitrary unions of types + { + anyOf: readonly JSONSchemaType[] + } + | { + oneOf: readonly JSONSchemaType[] + } + // this union allows for { type: (primitive)[] } style schemas + | ({ + type: (T extends number + ? JSONType<"number" | "integer", _partial> + : T extends string + ? JSONType<"string", _partial> + : T extends boolean + ? JSONType<"boolean", _partial> + : never)[] + } & (T extends number + ? NumberKeywords + : T extends string + ? StringKeywords + : T extends boolean + ? unknown + : never)) + // this covers "normal" types; it's last so typescript looks to it first for errors | ((T extends number ? { type: JSONType<"number" | "integer", _partial> @@ -91,29 +115,6 @@ export type JSONSchemaType = ( else?: PartialSchema not?: PartialSchema }) - // these two unions allow arbitrary unions of types - | { - anyOf: readonly JSONSchemaType[] - } - | { - oneOf: readonly JSONSchemaType[] - } - // this union allows for { type: (primitive)[] } style schemas - | ({ - type: (T extends number - ? JSONType<"number" | "integer", _partial> - : T extends string - ? JSONType<"string", _partial> - : T extends boolean - ? JSONType<"boolean", _partial> - : never)[] - } & (T extends number - ? NumberKeywords - : T extends string - ? StringKeywords - : T extends boolean - ? unknown - : never)) ) & { [keyword: string]: any $id?: string