Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Enable no-implicit-any-catch #5

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

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.

@leerob leerob closed this as completed Feb 11, 2025
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants