ObjectTypeGuardOptions.exactOptionalKeys?
ObjectTypeGuardOptions › exactOptionalKeys?
Type: Readonly<Record<OptionalKeys<T>, true>>
Switches the guard to EXACT optional properties, reading only the value's OWN keys. Listing it is the switch, so pass{} for a type with no optional key.Every optional key of
T must be listed, so an optional property later added to T fails to compile until it is. A listed key may then be absent, and its guard is not run; present, even as undefined, it must pass its guard. Any other key must be present. An inherited key counts as absent.Without it, a property is read with
Reflect.get, so an inherited one counts and an absent one reads as undefined, which the guard of an optional property must then accept.