Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Flag to type 'catch' variables as 'unknown'. #41016

Copy link
Copy link
@DanielRosenwasser

Description

@DanielRosenwasser
Issue body actions

In TypeScript 4.0, we allowed users to to annotate catch variables with : unknown; however, it'd be nice if we could have that be the default.

I could imagine a flag like --useUnknownInCatchVariables to switch the default type to be unknown.

// @useUnknownInCatchVariables: true

try {
  // ...
}
catch (e) {
  e.toUpperCase(); // error
}

Alternatively, I could also imagine a much broader flag that also types parameters as unknown as well.

Reactions are currently unavailable

Metadata

Metadata

Labels

Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeCommittedThe team has roadmapped this issueThe team has roadmapped this issueFix AvailableA PR has been opened for this issueA PR has been opened for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.