Skip to content

Commit c568dea

Browse files
committed
Drop | undefined from json schema types
1 parent 82b43fa commit c568dea

File tree

2 files changed

+89
-87
lines changed

2 files changed

+89
-87
lines changed

packages/zod/src/v4/core/json-schema.ts

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -10,105 +10,105 @@ export type Schema =
1010
// export type JsonType = "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
1111

1212
// export interface JSONSchema {
13-
// type?: string | undefined;
14-
// $id?: string | undefined;
15-
// id?: string | undefined;
16-
// $schema?: string | undefined;
17-
// $ref?: string | undefined;
18-
// $anchor?: string | undefined;
19-
// $defs?: { [key: string]: JSONSchema } | undefined;
20-
// definitions?: { [key: string]: JSONSchema } | undefined;
21-
// $comment?: string | undefined;
22-
// title?: string | undefined;
23-
// description?: string | undefined;
24-
// default?: unknown | undefined;
25-
// examples?: unknown[] | undefined;
26-
// readOnly?: boolean | undefined;
27-
// writeOnly?: boolean | undefined;
28-
// deprecated?: boolean | undefined;
29-
// allOf?: JSONSchema[] | undefined;
30-
// anyOf?: JSONSchema[] | undefined;
31-
// oneOf?: JSONSchema[] | undefined;
32-
// not?: JSONSchema | undefined;
33-
// if?: JSONSchema | undefined;
34-
// then?: JSONSchema | undefined;
35-
// else?: JSONSchema | undefined;
36-
// enum?: Array<string | number | boolean | null> | undefined;
37-
// const?: string | number | boolean | null | undefined;
13+
// type?: string ;
14+
// $id?: string ;
15+
// id?: string ;
16+
// $schema?: string ;
17+
// $ref?: string ;
18+
// $anchor?: string ;
19+
// $defs?: { [key: string]: JSONSchema } ;
20+
// definitions?: { [key: string]: JSONSchema } ;
21+
// $comment?: string ;
22+
// title?: string ;
23+
// description?: string ;
24+
// default?: unknown ;
25+
// examples?: unknown[] ;
26+
// readOnly?: boolean ;
27+
// writeOnly?: boolean ;
28+
// deprecated?: boolean ;
29+
// allOf?: JSONSchema[] ;
30+
// anyOf?: JSONSchema[] ;
31+
// oneOf?: JSONSchema[] ;
32+
// not?: JSONSchema ;
33+
// if?: JSONSchema ;
34+
// then?: JSONSchema ;
35+
// else?: JSONSchema ;
36+
// enum?: Array<string | number | boolean | null> ;
37+
// const?: string | number | boolean | null ;
3838
// [k: string]: unknown;
3939

4040
// /** A special key used as an intermediate representation of extends-style relationships. Omitted as a $ref with additional properties. */
4141
// // _ref?: JSONSchema;
42-
// _prefault?: unknown | undefined;
42+
// _prefault?: unknown ;
4343
// }
4444

4545
export type _JSONSchema = boolean | JSONSchema;
4646
export type JSONSchema = {
4747
[k: string]: unknown;
48-
$schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | undefined;
49-
$id?: string | undefined;
50-
$anchor?: string | undefined;
51-
$ref?: string | undefined;
52-
$dynamicRef?: string | undefined;
53-
$dynamicAnchor?: string | undefined;
54-
$vocabulary?: Record<string, boolean> | undefined;
55-
$comment?: string | undefined;
56-
$defs?: Record<string, JSONSchema> | undefined;
57-
type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer" | undefined;
58-
additionalItems?: _JSONSchema | undefined;
59-
unevaluatedItems?: _JSONSchema | undefined;
60-
prefixItems?: _JSONSchema[] | undefined;
61-
items?: _JSONSchema | _JSONSchema[] | undefined;
62-
contains?: _JSONSchema | undefined;
63-
additionalProperties?: _JSONSchema | undefined;
64-
unevaluatedProperties?: _JSONSchema | undefined;
65-
properties?: Record<string, _JSONSchema> | undefined;
66-
patternProperties?: Record<string, _JSONSchema> | undefined;
67-
dependentSchemas?: Record<string, _JSONSchema> | undefined;
68-
propertyNames?: _JSONSchema | undefined;
69-
if?: _JSONSchema | undefined;
70-
then?: _JSONSchema | undefined;
71-
else?: _JSONSchema | undefined;
72-
allOf?: JSONSchema[] | undefined;
73-
anyOf?: JSONSchema[] | undefined;
74-
oneOf?: JSONSchema[] | undefined;
75-
not?: _JSONSchema | undefined;
76-
multipleOf?: number | undefined;
77-
maximum?: number | undefined;
78-
exclusiveMaximum?: number | undefined;
79-
minimum?: number | undefined;
80-
exclusiveMinimum?: number | undefined;
81-
maxLength?: number | undefined;
82-
minLength?: number | undefined;
83-
pattern?: string | undefined;
84-
maxItems?: number | undefined;
85-
minItems?: number | undefined;
86-
uniqueItems?: boolean | undefined;
87-
maxContains?: number | undefined;
88-
minContains?: number | undefined;
89-
maxProperties?: number | undefined;
90-
minProperties?: number | undefined;
91-
required?: string[] | undefined;
92-
dependentRequired?: Record<string, string[]> | undefined;
93-
enum?: Array<string | number | boolean | null> | undefined;
94-
const?: string | number | boolean | null | undefined;
48+
$schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#";
49+
$id?: string;
50+
$anchor?: string;
51+
$ref?: string;
52+
$dynamicRef?: string;
53+
$dynamicAnchor?: string;
54+
$vocabulary?: Record<string, boolean>;
55+
$comment?: string;
56+
$defs?: Record<string, JSONSchema>;
57+
type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
58+
additionalItems?: _JSONSchema;
59+
unevaluatedItems?: _JSONSchema;
60+
prefixItems?: _JSONSchema[];
61+
items?: _JSONSchema | _JSONSchema[];
62+
contains?: _JSONSchema;
63+
additionalProperties?: _JSONSchema;
64+
unevaluatedProperties?: _JSONSchema;
65+
properties?: Record<string, _JSONSchema>;
66+
patternProperties?: Record<string, _JSONSchema>;
67+
dependentSchemas?: Record<string, _JSONSchema>;
68+
propertyNames?: _JSONSchema;
69+
if?: _JSONSchema;
70+
then?: _JSONSchema;
71+
else?: _JSONSchema;
72+
allOf?: JSONSchema[];
73+
anyOf?: JSONSchema[];
74+
oneOf?: JSONSchema[];
75+
not?: _JSONSchema;
76+
multipleOf?: number;
77+
maximum?: number;
78+
exclusiveMaximum?: number;
79+
minimum?: number;
80+
exclusiveMinimum?: number;
81+
maxLength?: number;
82+
minLength?: number;
83+
pattern?: string;
84+
maxItems?: number;
85+
minItems?: number;
86+
uniqueItems?: boolean;
87+
maxContains?: number;
88+
minContains?: number;
89+
maxProperties?: number;
90+
minProperties?: number;
91+
required?: string[];
92+
dependentRequired?: Record<string, string[]>;
93+
enum?: Array<string | number | boolean | null>;
94+
const?: string | number | boolean | null;
9595

9696
// metadata
97-
id?: string | undefined;
98-
title?: string | undefined;
99-
description?: string | undefined;
100-
default?: unknown | undefined;
101-
deprecated?: boolean | undefined;
102-
readOnly?: boolean | undefined;
103-
writeOnly?: boolean | undefined;
104-
examples?: unknown[] | undefined;
105-
format?: string | undefined;
106-
contentMediaType?: string | undefined;
107-
contentEncoding?: string | undefined;
108-
contentSchema?: JSONSchema | undefined;
97+
id?: string;
98+
title?: string;
99+
description?: string;
100+
default?: unknown;
101+
deprecated?: boolean;
102+
readOnly?: boolean;
103+
writeOnly?: boolean;
104+
examples?: unknown[];
105+
format?: string;
106+
contentMediaType?: string;
107+
contentEncoding?: string;
108+
contentSchema?: JSONSchema;
109109

110110
// internal
111-
_prefault?: unknown | undefined;
111+
_prefault?: unknown;
112112
};
113113

114114
// for backwards compatibility

play.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ const B = A.superRefine((val, ctx) => {
77
});
88
});
99

10-
B.parse("test"); // Should pass
10+
// B.parse("test"); // Should pass
11+
12+
console.log(navigator, { depth: null });

0 commit comments

Comments
 (0)