Lesson 7 / 7

Working with tsconfig and What’s Next

tsconfig.json

tsc --init

This generates a tsconfig.json file, which controls how the TypeScript compiler behaves for your whole project — which JavaScript version to compile down to, which folders to include, and how strict the type checking should be. Every real TypeScript project has one.

The strict flag

{n    "compilerOptions": {n        "strict": true,n        "target": "ES2020",n        "outDir": "./dist"n    }n}

"strict": true turns on TypeScript’s full set of strictness checks at once — including disallowing implicit any types and catching potential null/undefined access before it happens. Every new project should start with strict enabled; turning it on for a large existing JavaScript codebase later is far more work than starting with it from day one.

unknown vs any, revisited

function processInput(value: unknown) {n    if (typeof value === "string") {n        console.log(value.toUpperCase());   // safe -- TypeScript knows it's a string heren    }n}

unknown is the type-safe alternative to any mentioned back in Lesson 2 — you cannot use an unknown value for anything until you have actually checked what it is, the way typeof value === "string" does above. This forces you to handle every real possibility rather than silently trusting a value that might not be what you expect.

Where to go from here

  • React with TypeScript — the majority of professional React codebases today are written in TypeScript, building directly on the JavaScript course’s DOM and component concepts
  • Node.js with TypeScript — the exact same benefits, applied to backend code
  • Utility types — TypeScript ships with built-in helpers like Partial<T> and Pick<T, K> for transforming existing types, worth exploring once the basics here feel comfortable

You have completed the course

You now know TypeScript’s type system, interfaces, generics, and classes — enough to read and contribute to the large share of modern JavaScript codebases written in TypeScript today. Take the certification assessment next to prove it.