Code

tsconfig.json — the strict flags

In the code column — tsconfig.json with the strictest flags turned on. Lesson 15 deliberately shipped only the baseline (strict: true); now you flip on the rest, one by one — and watch new errors surface in code that compiled yesterday. Every one of them is an assumption you never handled.

After adding the flags:

npm run typecheck

Code that was green in lesson 17 now reports errors — that's the flags working, not you regressing. Fix them one at a time; each fix below explains what its flag just caught.

Important: strict: true is a bundle. It turns on many checks at once (strictNullChecks, noImplicitAny, stricter function-type rules, and more). The extra flags — noUncheckedIndexedAccess, exactOptionalPropertyTypes — are not part of strict; you enable them separately, and they're the strictest.

In practice noUncheckedIndexedAccess is the one that "hurts most" — because it touches every array/object index:

const first = pictures[0];        // Apod | undefined (not Apod!)
first.title;                      // ❌ 'first' is possibly 'undefined'

Annoying at first, but that's exactly the payoff: it surfaces an assumption you never handled — "what if the array is empty?". In the vanilla code that was a silent undefined.title crash.

Tip. Some flags (noUnusedLocals, noUnusedParameters, noFallthroughCasesInSwitch) are less about types and more about cleanliness: an unused variable or a fall-through switch case is almost always a bug or unfinished code. Strict mode catches not just type slips but logical oversights too.