Sha256: 672c1ebc4fa15a1c9b4911f1c68de2bc889f4d166a68c5be8f1e61f94014e9d8

Contents?: true

Size: 658 Bytes

Versions: 28

Compression:

Stored size: 658 Bytes

Contents

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>;

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.25 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.24 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.23 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.22 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.21 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.20 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.19 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.18 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.17 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.16 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.15 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.14 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.13 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.12 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.11 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.10 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.9 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.8 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts
clapton-0.0.7 lib/clapton/javascripts/node_modules/type-fest/source/single-key-object.d.ts