haejunejung / ts-typekit

🧰 A Collection of TypeScript Utility Types
https://ts-typekit.vercel.app
MIT License
9 stars 0 forks source link

Support for `IsTuple` #28

Closed haejunejung closed 2 months ago

haejunejung commented 2 months ago

It provides support for IsTuple.

Tuples and arrays are handled differently in TypeScript. Tuples have a fixed length with potentially different types at each position, while arrays are variable-length and typically homogeneous. It allows you to apply specific login or constraints that are unique to tuples versus array.

For example as below.

type T0 = IsTuple<[number]> // true
type T1 = IsTuple<[number, string> // true

type T2 = IsTuple<[]> // false
type T3 = IsTuple<number[]> // false
type T4 = IsTuple<Array<number>> // false