Represents a strictly empty plain object, the `{}` value.
5
6
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
7
8
@example
9
```
10
import type {EmptyObject} from 'type-fest';
11
12
// The following illustrates the problem with `{}`.
13
const foo1: {} = {}; // Pass
14
const foo2: {} = []; // Pass
15
const foo3: {} = 42; // Pass
16
const foo4: {} = {a: 1}; // Pass
17
18
// With `EmptyObject` only the first case is valid.
19
const bar1: EmptyObject = {}; // Pass
20
const bar2: EmptyObject = 42; // Fail
21
const bar3: EmptyObject = []; // Fail
22
const bar4: EmptyObject = {a: 1}; // Fail
23
```
24
25
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.