Skip to content

Glossary: TypeScript Basics

catch variable (error is unknown)

Also written: useUnknownInCatchVariables, catch block

With `strict`, the `error` in `catch (error)` has type `unknown`, because JavaScript can throw any value. Narrow it with `instanceof Error`, or use `String(error)`, before reading `.message`.

Where the book teaches it

Related terms

unknowninstanceofstrict