Type alias ObjectOptional<Schema>

ObjectOptional<Schema>: { [ Key in keyof Schema as Schema[Key] extends ExactOptionalGuard ? Key : never]?: Schema[Key] extends ExactOptionalGuard & infer Original ? Original : never } & { [ Key in keyof Schema as Schema[Key] extends ExactOptionalGuard ? never : Key]: Schema[Key] }

A helper type to make properties with undefined in their type optional, but not undefined itself.

Deprecated

Use ObjectType and/or ExactOptionalize from @metamask/superstruct@>=3.2.0 instead.

Example

type Foo = ObjectOptional<{ foo: string | undefined }>;
// Foo is equivalent to { foo?: string }

Type Parameters

  • Schema extends Record<string, unknown>