Skip to content

Commit 2e4850a

Browse files
authored
Fix: Additional properties to not be any by default (#503)
1 parent f8269af commit 2e4850a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

typescript/packages/common-builder/src/schema-to-ts.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export type Schema<
5252
T extends
5353
{ additionalProperties: infer AP extends boolean | JSONSchema }
5454
? AP
55-
: true,
55+
: false,
5656
GetDefaultKeys<T>
5757
>
5858
: Record<string, unknown>
@@ -122,7 +122,9 @@ type ObjectFromProperties<
122122
}
123123
// Additional properties
124124
& (
125-
AP extends false ? Record<string | number | symbol, never>
125+
AP extends false
126+
// Additional properties off => no-op instead of empty record
127+
? Record<never, never>
126128
: AP extends true ? { [key: string]: unknown }
127129
: AP extends JSONSchema
128130
? { [key: string]: Schema<AP, Root, DecrementDepth<Depth>> }
@@ -206,7 +208,7 @@ export type SchemaWithoutCell<
206208
T extends
207209
{ additionalProperties: infer AP extends boolean | JSONSchema }
208210
? AP
209-
: true,
211+
: false,
210212
GetDefaultKeys<T>
211213
>
212214
: Record<string, unknown>
@@ -271,8 +273,8 @@ type ObjectFromPropertiesWithoutCell<
271273
// Additional properties
272274
& (
273275
AP extends false
274-
// Additional properties off => empty
275-
? Record<string | number | symbol, never>
276+
// Additional properties off => no-op instead of empty record
277+
? Record<never, never>
276278
: AP extends true
277279
// Additional properties on => unknown
278280
? { [key: string]: unknown }

0 commit comments

Comments
 (0)