Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement tuples in typescript

Shulou Source: shulou.com Published: 2022-06-01 04:52:14 09月23日 Update

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.

Tags: Articles types elements more good practical same content multiple array quantity article knowledge reference help application related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Redmi MariaDB OPPO Reno Microsoft