Creates a type that represents true or false depending on whether the given type has any optional fields.
true
false
This is useful when you want to create an API whose behavior depends on the presence or absence of optional fields.
import type {HasOptionalKeys, OptionalKeysOf} from 'type-fest';type UpdateService<Entity extends object> = { removeField: HasOptionalKeys<Entity> extends true ? (field: OptionalKeysOf<Entity>) => Promise<void> : never} Copy
import type {HasOptionalKeys, OptionalKeysOf} from 'type-fest';type UpdateService<Entity extends object> = { removeField: HasOptionalKeys<Entity> extends true ? (field: OptionalKeysOf<Entity>) => Promise<void> : never}
Creates a type that represents
trueorfalsedepending on whether the given type has any optional fields.This is useful when you want to create an API whose behavior depends on the presence or absence of optional fields.