persona-community-5/.pnpm-store/v3/files/a4/d7479dcf1e834d0ea3ad75de040fd97aaa26b4d42584a603f21dd08686801c017075a6c117009e876ff0177f60d2fb94b98dca52ba9a1ba770893b62b0d839
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

30 lines
658 B
Plaintext

import type {IfEmptyObject} from './if-empty-object';
import type {IsUnion} from './internal';
/**
Create a type that only accepts an object with a single key.
@example
```
import type {SingleKeyObject} from 'type-fest';
const someFunction = <T>(parameter: SingleKeyObject<T>) => {};
someFunction({
value: true
});
someFunction({
value: true,
otherKey: true
});
// Error: Argument of type '{value: boolean; otherKey: boolean}' is not assignable to parameter of type 'never'.ts(2345)
```
@category Object
*/
export type SingleKeyObject<ObjectType> =
IsUnion<keyof ObjectType> extends true
? never
: IfEmptyObject<ObjectType, never, ObjectType>;