Galdor
Galdor

Reputation: 1955

How to define array type in typescript?

I am using variables of the following type in typescript:

[[string, string], string][]

Is there a way to define this as type so I don't have to repeat this definition everywhere in my code?

Upvotes: 1

Views: 931

Answers (1)

John Weisz
John Weisz

Reputation: 31924

You can define a type:

type stringTuple = [[string, string], string][];

And then later use it similar to how you would use a class or interface:

var array: stringTuple;

Upvotes: 4

Related Questions