Day 7 of 14 30 minTuplesreadonlyas const
Type collections and fixed sets of values. Use typed arrays and readonly arrays, model fixed-length records with tuples, and compare enums with the literal unions and const objects most modern TypeScript code prefers.
By the end of today you can
- Type arrays and readonly arrays, and see how array methods keep their types
- Use tuples for fixed-length, fixed-position data
- Write enums and understand what they compile to
- Prefer literal unions or as const objects where they fit better
- Use as const to keep literal types
What's inside
- 4 sections
- 2 diagrams and mind maps
- 5 code examples you can run
- 5-question quiz
- 1Typed arrays
- 2Tuples: fixed length, fixed positions
- 3Enums
- 4Lighter alternatives: literal unions and as const
Sign in free to read this lesson
Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.
Sign in free