TypeScript · Junior · Question 58 of 75

Why can't you check if (data is User) at runtime?

Explanation

TypeScript only checks code at compile time. Data from APIs, localStorage or forms must be validated by real code.

Further reading

Problem with a question

TypeScript · Junior · question 58

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz