Back to Type Challenges

README

questions/04484-medium-istuple/README.md

latest2.0 KB
Original Source
<!--info-header-start--><h1>IsTuple </h1><blockquote><p>by jiangshan <a href="https://github.com/jiangshanmeta" target="_blank">@jiangshanmeta</a></p></blockquote><p><a href="https://tsch.js.org/4484/play" target="_blank"></a> </p><!--info-header-end-->

Implement a type IsTuple, which takes an input type T and returns whether T is tuple type.

For example:

typescript
type case1 = IsTuple<[number]> // true
type case2 = IsTuple<readonly [number]> // true
type case3 = IsTuple<number[]> // false
<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/4484/answer" target="_blank"></a> <a href="https://tsch.js.org/4484/solutions" target="_blank"></a> <hr><h3>Related Challenges</h3><a href="https://github.com/type-challenges/type-challenges/blob/main/questions/01042-medium-isnever/README.md" target="_blank"></a> <a href="https://github.com/type-challenges/type-challenges/blob/main/questions/01097-medium-isunion/README.md" target="_blank"></a> <a href="https://github.com/type-challenges/type-challenges/blob/main/questions/00223-hard-isany/README.md" target="_blank"></a> <!--info-footer-end-->