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

unknown type declaration for catch argument doesn't work in js #39836

Closed
elibarzilay opened this issue Jul 30, 2020 · 2 comments · Fixed by #42392
Closed

unknown type declaration for catch argument doesn't work in js #39836

elibarzilay opened this issue Jul 30, 2020 · 2 comments · Fixed by #42392
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Domain: JavaScript The issue relates to JavaScript specifically Fixed A PR has been merged for this issue

Comments

@elibarzilay
Copy link
Contributor

From #36775, unknown doesn't work in JS with a jsdoc comment:

try {
	// something
} catch (/** @type {unknown} */ err) {
	// `err` is still typed as `any`:
	err; // $ExpectType unknown
}
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Aug 17, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Aug 17, 2020
@bajtos
Copy link

bajtos commented Sep 11, 2020

Because of this bug, it's not possible to use @typescript-eslint/no-implicit-any-catch to lint JavaScript code using JSDoc comments for type annotations (see https://devblogs.microsoft.com/typescript/how-to-upgrade-to-typescript-without-anybody-noticing-part-2/).

@DanielRosenwasser
Copy link
Member

Thanks @a-tarasyuk!

@DanielRosenwasser DanielRosenwasser added checkJs Relates to checking JavaScript using TypeScript Domain: JavaScript The issue relates to JavaScript specifically labels Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Domain: JavaScript The issue relates to JavaScript specifically Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants