Skip to content
Guest
Learn TypeScript · Course Syllabus Show lessons
TypeScript Foundations · 8 min read · Intermediate

Types, Inference & Strict Mode

Understand how TypeScript infers types automatically, when to annotate explicitly, and why strict mode prevents null bugs.

What you'll learn

  • Let TypeScript infer local variables while explicitly typing function parameters
  • Avoid the any escape hatch in favor of unknown
  • Enable strict mode for null and undefined safety

TypeScript is JavaScript with static type checking. Types are checked at compile time and erased completely before your code runs, giving you zero runtime overhead and instant editor autocomplete.

Fill-in-the-Blank Exercise

Typed Function Signature

Annotate name as string and the return type as string.

function greet(name: ):  {
return "Hello, " + name;
}

Live Code Lab

TypeScriptbasics.ts
Expected OutputClick “Run Live” to compile with TypeScript 5.6
TypeScript 5 (6 lessons)

Check Your Understanding

Score: 0 / 1

1. Why is unknown safer than any in TypeScript?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind