<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨 Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Please help us by doing the following steps before logging an issue: * Search: https://github.com/Microsoft/TypeScript/search?type=Issues * Read the FAQ, especially the "Common Feature Requests" section: https://github.com/Microsoft/TypeScript/wiki/FAQ --> ## Search Terms <!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily --> catch clause unknown exception ## Suggestion <!-- A summary of what you'd like to see added or changed --> Now any kind of type annotation on catch clauses is not allowed. In my understanding, it's because that it's unsafe to annotate like `catch (err: SpecialError)` since any value will be captured actually. However, due to the type of `err` is `any`, it's also not type safe. So I suggest to allow annotating `unknown` , as most safe typing. (And annotation with any other type won't be allowed as is) <!-- ## Use Cases --> <!-- What do you want to use this for? What shortcomings exist with current approaches? --> ## Examples <!-- Show how this would be used and what the behavior would be --> ``` try { throw 42; } catch (err) { console.error(err.specialFunction()); } ``` can be written safer as ``` try { throw 42; } catch (err: unknown) { if (err instanceof SpecialError) { console.error(err.specialFunction()); } else { ... } } ``` ## Related Issue #20024 ## Checklist My suggestion meets these guidelines: * [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code * [x] This wouldn't change the runtime behavior of existing JavaScript code * [x] This could be implemented without emitting different JS based on the types of the expressions * [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.) * [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).