TypeScript · Junior · Question 36 of 75
What is the type of e in catch (e) with strict enabled?
- ✓Correct answer:
unknown - 2
Error(the built-in class) - 3
any(as without strict)
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).