HiveBrain v1.2.0
Get Started
← Back to all entries
snippettypescriptCritical

Create strongly typed array of arrays in TypeScript

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
arraytypescriptarraysstronglytypedcreate

Problem

In a language like C# I can declare a list of lists like:

List> list_of_lists;


Is there a similar way to declare a strongly typed array of arrays in TypeScript? I tried the following approaches but neither compiles.

var list_of_lists:int[][];
var list_of_lists:Array;

Solution

int is not a type in TypeScript. You probably want to use number:

var listOfLists : number[][];

Code Snippets

var listOfLists : number[][];

Context

Stack Overflow Q#23161486, score: 223

Revisions (0)

No revisions yet.