-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(IsTuple): Add IsTuple type documentation
- Loading branch information
1 parent
b148409
commit 1920790
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# IsTuple\<T> | ||
|
||
## Overview | ||
|
||
주어진 타입이 튜플 타입인지 여부를 판별하는 타입이에요. | ||
|
||
## Syntax | ||
|
||
```ts | ||
type IsTuple<T> = T extends any[] | readonly any[] | ||
? number extends T['length'] | ||
? false | ||
: true | ||
: false; | ||
``` | ||
|
||
- **T**: 검사할 타입이에요. | ||
|
||
## Examples | ||
|
||
#### Example #1 | ||
|
||
```ts | ||
type T0 = IsTuple<[]>; // true | ||
type T1 = IsTuple<[number]>; // true | ||
type T2 = IsTuple<[number, string]>; // true | ||
|
||
type T3 = IsTuple<any[]>; // false | ||
type T4 = IsTuple<unknown[]>; // false | ||
type T5 = IsTuple<number[]>; // false | ||
type T6 = IsTuple<Array<number>>; // false | ||
type T7 = IsTuple<ReadonlyArray<number>>; // false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# IsTuple\<T> | ||
|
||
## Overview | ||
|
||
A type that determines whether the given type is a tuple type. | ||
|
||
## Syntax | ||
|
||
```ts | ||
type IsTuple<T> = T extends any[] | readonly any[] | ||
? number extends T['length'] | ||
? false | ||
: true | ||
: false; | ||
``` | ||
|
||
- **T**: The type to check. | ||
|
||
## Examples | ||
|
||
#### Example #1 | ||
|
||
```ts | ||
type T0 = IsTuple<[]>; // true | ||
type T1 = IsTuple<[number]>; // true | ||
type T2 = IsTuple<[number, string]>; // true | ||
|
||
type T3 = IsTuple<any[]>; // false | ||
type T4 = IsTuple<unknown[]>; // false | ||
type T5 = IsTuple<number[]>; // false | ||
type T6 = IsTuple<Array<number>>; // false | ||
type T7 = IsTuple<ReadonlyArray<number>>; // false | ||
``` |