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

Enable no-implicit-any-catch #5

Open
mrmckeb opened this issue Mar 29, 2022 · 4 comments
Open

Enable no-implicit-any-catch #5

mrmckeb opened this issue Mar 29, 2022 · 4 comments
Labels

Comments

@mrmckeb
Copy link
Contributor

mrmckeb commented Mar 29, 2022

This was a recommendation from @dglsparsons:

We have the useUnknownInCatchVariables setting enabled in our tsconfig (it’s part of the strict family).

But it only applies to try {} catch(e) {} blocks, not to Promise.catch (which is still typed as any). So it causes a kinda weird inconsistency in how exceptions are handled and makes it harder to be type-safe.

There is a typescript issue to update the Promise.catch() behaviour here microsoft/TypeScript#45602, but it is yet to be implemented.

On it, however, it specifically calls out this ESLint rule: https://github.com/cartant/eslint-plugin-etc/blob/main/docs/rules/no-implicit-any-catch.md

I think this would help us be more standardised in how we do exception handling, at least, until the above issue is closed/implemented.

@mrmckeb mrmckeb added the eslint label Mar 29, 2022
@mrmckeb mrmckeb added this to the April 2022 milestone Mar 31, 2022
@mrmckeb
Copy link
Contributor Author

mrmckeb commented Sep 21, 2022

@dglsparsons what do you think of modifying the types instead?

@mrmckeb mrmckeb removed this from the September 2022 milestone Sep 21, 2022
@dglsparsons
Copy link

@mrmckeb As in redefining the types of Promise.catch? Is that easy enough to do?

@mrmckeb
Copy link
Contributor Author

mrmckeb commented Sep 26, 2022

Yes, you can see some examples in the issue you linked:
microsoft/TypeScript#45602 (comment)

It might be worth a shot, but I'm surprised they haven't changed this in TS itself yet.

@dglsparsons
Copy link

me too tbh.

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

No branches or pull requests

2 participants