Skip to content

Commit 8bc23d2

Browse files
committed
Comment
1 parent 7889f1c commit 8bc23d2

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/schema/static/required.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ import type { XProperties } from '../types/properties.ts'
3535
// ------------------------------------------------------------------
3636
// XStaticRequired
3737
// ------------------------------------------------------------------
38-
export type XStaticRequired<Stack extends string[], Root extends XSchema, Schema extends XSchema, Keys extends string[],
39-
// Note: We only produce a property set if the Required keyword is isolated without Properties. This is because the
40-
// Properties inference will handle Required in full, but where an isolated Required implies that the defined keys
41-
// are required but should accept anything (unknown).
38+
export type XStaticRequired<_Stack extends string[], _Root extends XSchema, Schema extends XSchema, Keys extends string[],
39+
// If the 'properties' keyword is present, we return {} and trust the 'Properties' inference
40+
// path to resolve the 'required' keyword. If 'properties' is absent, we generate an object
41+
// where each key is assigned an 'unknown' type, as 'required' without 'properties'
42+
// still implies that the keys should exist on the object.
4243
Result extends Record<PropertyKey, unknown> = Schema extends XProperties ? {} : Record<Keys[number], unknown>
4344
> = Result

0 commit comments

Comments
 (0)