Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript: variables in catch should be unknown on default settings #13531

Closed
davimiku opened this issue Jan 29, 2022 · 2 comments
Closed

TypeScript: variables in catch should be unknown on default settings #13531

davimiku opened this issue Jan 29, 2022 · 2 comments
Labels
duplicate a duplicate of another issue

Comments

@davimiku
Copy link

With the following code:

try {
  throw 'not an Error object'
} catch (error) {
  console.error(error.message)
}

The Deno language server shows the type of the error variable as any, which should be unknown and a compiler error. Below is a screenshot of the Deno language server running in Visual Studio Code.

catch_variable_any

Version information:

deno 1.18.0 (release, x86_64-unknown-linux-gnu)
v8 9.8.177.6
typescript 4.5.2

Since TypeScript v4.4, useUnknownInCatchVariables is activated when strict is true. According to the documentation on deno.land, the default value of strict is true in Deno's default tsconfig, so useUnknownInCatchVariables would be implicitly true by default also.

@dsherret dsherret added the duplicate a duplicate of another issue label Jan 29, 2022
@dsherret
Copy link
Member

It is a major change. See and discuss in #11826

@davimiku
Copy link
Author

OK got it, I see. I will open a separate issue to fix the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants