Introduction to TypeScript. Special TypeScript data types (opens in new tab)
Arrays and tuples array - collection of items (similar to JavaScript). In TypeScript we can specify what value types we expect for items to be: let arr: number[] = []; arr[0] = 1; arr[0] += "string"; // Type 'string' is not assignable to type 'number' we can declare nested arrays like this: let arr: string[][] = [["string1"], ["string2"], []]. tuples - fixed length array that has predefined types for each position: let tup: [number, string] = [1, "text"]; tup[0] = 2; tup[1] = 3; //Type 'numbe...
Read the original article