frontend/.pnpm-store/v3/files/61/a612651c987b221b0f29cde889f9b23a3a3931e8a5e8a18a8c21f966a51efa9f955050422549d659ad8ca0a3bc736da20a5e185abd8e0b26a36ff7ac0a5295

22 lines
667 B
Plaintext

import type {OptionalKeysOf} from './optional-keys-of';
/**
Creates a type that represents `true` or `false` depending 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.
@example
```
import type {HasOptionalKeys, OptionalKeysOf} from 'type-fest';
type UpdateService<Entity extends object> = {
removeField: HasOptionalKeys<Entity> extends true
? (field: OptionalKeysOf<Entity>) => Promise<void>
: never
}
```
@category Utilities
*/
export type HasOptionalKeys<BaseType extends object> = OptionalKeysOf<BaseType> extends never ? false : true;