TypeScript · Junior · Question 36 of 75

What is the type of e in catch (e) with strict enabled?

Explanation

With the useUnknownInCatchVariables flag (part of strict), e is unknown, since anything can be thrown, not just an Error. Check before use: if (e instanceof Error) console.log(e.message).

Further reading

Problem with a question

TypeScript · Junior · question 36

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