Courses
TypeScript for Beginners: Catch Wrong Data Before It Runs
Check Yourself: Types You Cannot Skip
Five scenario questions on inference, null, shapes, optional properties and any. If you miss more than one, reread the lessons in this section.
Course content
Join this Course
Sign in to save your progress.
-
Before You Write Types
-
What TypeScript Adds on Top of JavaScript
-
Install TypeScript and Run Your First .ts File
-
-
-
Types You Cannot Skip
-
Annotating Variables Without Fighting the Compiler
-
Arrays, Objects and Nested Shapes
-
Optional, Readonly and Why any Is a Trap
-
-
-
Functions That State Their Deal
-
Parameter and Return Types
-
Optional and Default Parameters Without Surprises
-
-
-
Shapes You Can Reuse
-
Interfaces vs type Aliases: Pick One and Stick With It
-
Unions, Literals and Narrowing With typeof and in
-
-
-
Compile Without the Mystery
-
tsconfig.json: target, module and strict
-
Reading tsc Errors Without Panicking
-
-
- Final Check: TypeScript for Beginners
1.
You write let count = 0; and a few lines later count = "zero";. There is no annotation anywhere. What does the compiler do?
2.
A new file contains only let name: string = "Ana"; and tsc reports Cannot redeclare block-scoped variable name. You declared it once. What is going on and what is the fix?
The compiler counts the string Ana as a second declaration.
The word name is reserved by JavaScript and can never be a variable.
You need to write var instead of let.
A file with no import or export is a script that shares the global scope with the browser definitions, which already declare name. Add export {} or pick another name.
3.
You write const product: { title: string; price: number } = { title: "Pen" };. What does the compiler tell you?
4.
A type has subtitle?: string. Your code calls product.subtitle.toUpperCase() directly. The compiler refuses. Why?
5.
A function copies a value out of a variable typed any into a variable typed number. The value is really the string "three", and a later call to toFixed fails. Where did the checking stop?
About
Five scenario questions on inference, null, shapes, optional properties and any. If you miss more than one, reread the lessons in this section.
- Duration
- 5 min
- Last update
- 10/12/2026
Was this helpful?
0
0
Comments (0)
Sign in to commentNo comments yet.