In strict TypeScript a catch parameter is unknown. Nothing tells you which throws are possible.
Every recovery decision starts with a guess.
const result = someLibraryFunction()
// `e` is unknown. Casting is a bet.
const message = (e as Error).message
There is no compiler check for “have I handled every failure mode of this function”. The documentation, if it exists, is the only specification.
Watch out. e instanceof Error is the most common defensive check in
hand-written catch clauses. The test in this beat throws a plain
string — the check returns false, and message is undefined.
Your turn: confirm that a thrown string slips past e instanceof Error at runtime. The assertion checks typeof e, not the cast.