diff --git a/docs/.vitepress/en.mts b/docs/.vitepress/en.mts index f7783d6..7b33e5a 100644 --- a/docs/.vitepress/en.mts +++ b/docs/.vitepress/en.mts @@ -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' }, ], }, ], diff --git a/docs/.vitepress/ko.mts b/docs/.vitepress/ko.mts index 6f7fd17..cd795c4 100644 --- a/docs/.vitepress/ko.mts +++ b/docs/.vitepress/ko.mts @@ -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' }, ], }, ], diff --git a/docs/ko/reference/predicate/IsTuple.md b/docs/ko/reference/predicate/IsTuple.md new file mode 100644 index 0000000..e2e35a3 --- /dev/null +++ b/docs/ko/reference/predicate/IsTuple.md @@ -0,0 +1,33 @@ +# IsTuple\ + +## Overview + +주어진 타입이 튜플 타입인지 여부를 판별하는 타입이에요. + +## Syntax + +```ts +type IsTuple = 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; // false +type T4 = IsTuple; // false +type T5 = IsTuple; // false +type T6 = IsTuple>; // false +type T7 = IsTuple>; // false +``` diff --git a/docs/reference/predicate/IsTuple.md b/docs/reference/predicate/IsTuple.md new file mode 100644 index 0000000..5d2d9ce --- /dev/null +++ b/docs/reference/predicate/IsTuple.md @@ -0,0 +1,33 @@ +# IsTuple\ + +## Overview + +A type that determines whether the given type is a tuple type. + +## Syntax + +```ts +type IsTuple = 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; // false +type T4 = IsTuple; // false +type T5 = IsTuple; // false +type T6 = IsTuple>; // false +type T7 = IsTuple>; // false +```