Skip to content

Commit

Permalink
docs(IsTuple): Add IsTuple type documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
haejunejung committed Aug 24, 2024
1 parent b148409 commit 1920790
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/en.mts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default defineConfig({
items: [
{ text: 'IsArray', link: '/reference/predicate/IsArray' },
{ text: 'IsEqual', link: '/reference/predicate/IsEqual' },
{ text: 'IsTuple', link: '/reference/predicate/IsTuple' },
],
},
],
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/ko.mts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default defineConfig({
items: [
{ text: 'IsArray', link: '/ko/reference/predicate/IsArray' },
{ text: 'IsEqual', link: '/ko/reference/predicate/IsEqual' },
{ text: 'IsTuple', link: '/ko/reference/predicate/IsTuple' },
],
},
],
Expand Down
33 changes: 33 additions & 0 deletions docs/ko/reference/predicate/IsTuple.md
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
```
33 changes: 33 additions & 0 deletions docs/reference/predicate/IsTuple.md
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
```

0 comments on commit 1920790

Please sign in to comment.