With typescript 3.0, you can have your own utility function:
const tuple = <T extends any[]>(...args: T): T => args
And use it this way:
const tup = tuple(1, 2) // tup type is [number, number]
More Related Contents:
- How to fix TS2322: “could be instantiated with a different subtype of constraint ‘object'”?
- Angular 2 custom form input
- How to check the object type on runtime in TypeScript?
- TypeScript how to create a generic type alias for a generic function?
- What is the syntax for Typescript arrow functions with generics?
- How to extend String Prototype and use it next, in Typescript?
- Types in object destructuring
- Angular 2: Convert Observable to Promise
- How to prepare release version with SystemJS and Gulp?
- Angular2 canActivate() calling async function
- Purpose of declare keyword in TypeScript
- How to declare a Fixed length Array in TypeScript
- Is it possible to restrict number to a certain range
- Higher-order type functions in TypeScript?
- Angular 6 View is not updated after changing a variable within subscribe
- ESLint – Configuring “no-unused-vars” for TypeScript
- Object destructuring with property names that are not valid variable names
- How to install Typescript typings for google maps
- How to declare a type as nullable in TypeScript?
- How to use Object.values with typescript?
- is there a way to get all required properties of a typescript object
- Typescript: ReturnType of overloaded function
- What TypeScript version is Visual Studio Code using? How to update it?
- Why does TypeScript track mutation of function static properties?
- Array VS Type[] in Typescript
- What’s the meaning of “=>” in TypeScript? (Fat Arrow)
- How to use array.map with tuples in typescript?
- how to remove properties via mapped type in TypeScript
- Simple function with conditional type
- Iterable cannot confirm generic T in function