Complex Types
Learn how to apply types to more complex data structures like arrays and objects.
StartKey Concepts
Review core concepts you need to learn to master this subject
TypeScript Type for One-dimensional Array
TypeScript Generic Type for One-Dimensional Array
TypeScript Type for Multi-dimensional Array
TypeScript Empty Array Initialization
TypeScript Tuple Type
TypeScript Tuple Type Syntax
TypeScript Tuple Type Length and Order
TypeScript Tuple Array Assignment
TypeScript Type for One-dimensional Array
TypeScript Type for One-dimensional Array
// zipcodes is an array of strings
let zipcodes: string[] = ['03255', '02134', '08002', '03063'];
// Pushing a number to zipcodes will generate an error
// Error: Argument of type 'number' is not assignable to parameter of type 'string'.
zipcodes.push(90210);
The type annotation for a one-dimensional array in TypeScript is similar to a primitive data type, except we add a []
after the type.
Arrays
Lesson 1 of 2
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory