Length of Tuple
introduction#
For given a tuple, you need create a generic Length, pick the length of the tuple
For example
ts
View on GitHubts
start point#
tsTry/* _____________ Your Code Here _____________ */typeLength <T extends any> = any;Â/* _____________ Test Cases _____________ */consttesla = ['tesla', 'model 3', 'model X', 'model Y'] as const;constspaceX = ['FALCON 9','FALCON HEAVY','DRAGON','STARSHIP','HUMAN SPACEFLIGHT',] as const;Âtypecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Length <typeoftesla >, 4>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Length <typeofspaceX >, 5>>,];
Take the ChallengetsTry/* _____________ Your Code Here _____________ */typeLength <T extends any> = any;Â/* _____________ Test Cases _____________ */consttesla = ['tesla', 'model 3', 'model X', 'model Y'] as const;constspaceX = ['FALCON 9','FALCON HEAVY','DRAGON','STARSHIP','HUMAN SPACEFLIGHT',] as const;Âtypecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Length <typeoftesla >, 4>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Length <typeofspaceX >, 5>>,];