Skip to content

Commit 4ef997a

Browse files
committed
doc: fix jsDoc examples in IsEmptyObject and IsEmptyArray
1 parent 1cb58fd commit 4ef997a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

source/empty-object.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ Returns a `boolean` for whether the type is strictly equal to an empty plain obj
3737
```
3838
import type {IsEmptyObject} from 'type-fest';
3939
40-
type Pass = IsEmptyObject<{}>; //=> true
41-
type Fail = IsEmptyObject<[]>; //=> false
42-
type Fail = IsEmptyObject<null>; //=> false
40+
type Pass1 = IsEmptyObject<{}>; //=> true
41+
type Pass2 = IsEmptyObject<Record<keyof any, never>>; //=> true
42+
type Fail1 = IsEmptyObject<[]>; //=> false
43+
type Fail2 = IsEmptyObject<null>; //=> false
4344
```
4445
4546
@see EmptyObject

source/internal/array.d.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export type IsArrayReadonly<T extends UnknownArray> = If<IsNever<T>, false, T ex
9999
/**
100100
Represents an empty array, the `[]` or `readonly []` value.
101101
*/
102-
export type EmptyArray = readonly [] | []; // The extra `[]` just to prevent TS from expanding the type.
102+
export type EmptyArray = readonly [] | []; // The extra `[]` is just to prevent TS from expanding the type.
103103

104104
/**
105105
Returns a `boolean` for whether the type is an empty array, the `[]` or `readonly []` value.
@@ -108,10 +108,11 @@ Returns a `boolean` for whether the type is an empty array, the `[]` or `readonl
108108
```
109109
import type {IsEmptyArray} from 'type-fest';
110110
111-
type Pass = IsEmptyArray<[]>; //=> true
112-
type Pass = IsEmptyArray<readonly []>; //=> true
113-
type Fail = IsEmptyArray<[0]>; //=> false
114-
type Fail = IsEmptyArray<[0?]>; //=> false
111+
type Pass1 = IsEmptyArray<[]>; //=> true
112+
type Pass2 = IsEmptyArray<readonly []>; //=> true
113+
type Fail1 = IsEmptyArray<[0]>; //=> false
114+
type Fail2 = IsEmptyArray<[0?]>; //=> false
115+
type Fail3 = IsEmptyArray<...string[]>; //=> false
115116
```
116117
117118
@see EmptyArray

0 commit comments

Comments
 (0)