Find the type error: 12 levels reading TS errors and fixing annotations. A TypeScript debugging game that trains your eye for type mismatches.
In TypeScript, every variable has a type. If you declare let x: string, then x can only be filled with a string, not a number or another type.
An array in TypeScript can be given an element type. number[] means every element must be a number, string[] means they must all be strings.
The generic type Array<T> means the same as T[]. Array<number> = number[], Array<string> = string[]. Every element must match the type T.
With strictNullChecks (the default in modern TypeScript), null and undefined must be stated explicitly using a union type.
If a variable has a union type (say string | number), you have to narrow the type before accessing a property that only exists on one of the types.
A readonly property can only be set when the object is created. After that, its value can't be changed. To "change" it, make a new object.