How to implement tuples in typescript
This article will explain in detail how to implement tuples in typescript. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Tuple
Represents an array of known number and type of elements, each of which does not have to be the same type.
Let x: [string, number]; x = ['hello', 10]
When issuing multiple requests, you can apply:
Const requestList: any [] = [http.get ('http://some.1')]; / / set to any [] type if (flag) {requestList [1] = (http.get (' http://some.2'));} const [{data: a}, response] = await Promise.all (requestList) as [Response, Response?]) This is the end of the article on "how to implement tuples in typescript". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.