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

Minimize the use of any types #751

Closed
mcmire opened this issue Mar 23, 2022 · 6 comments
Closed

Minimize the use of any types #751

mcmire opened this issue Mar 23, 2022 · 6 comments

Comments

@mcmire
Copy link
Contributor

mcmire commented Mar 23, 2022

Right now TypeScript ESLint's no-explicit-any rule is turned off in our global ESLint config: https://github.com/MetaMask/eslint-config/blob/ec27156931a0cda1b34ff46937b8296742dcb1c0/packages/typescript/src/index.js#L39. While changing this setting globally is a different issue, we should consider enabling it just for controllers. We should be using any as little as possible, because using it indicates that something is not typed properly, whether it is a dependency or our own code.

Enabling this rule produces 335 violations across ~15 files.

This issue is partially blocked by #728.

@BboyAkers
Copy link

@mcmire would it help to reactor the any keywords into unknown? It's more type safe than any

@mcmire
Copy link
Contributor Author

mcmire commented Mar 11, 2023

@BboyAkers We could, and that would certainly highlight the fact that we are using any. But if we are changing types, it would be even better to see if we can figure out more accurate types to use rather than defaulting to unknown.

@BboyAkers
Copy link

BboyAkers commented Mar 11, 2023

@BboyAkers We could, and that would certainly highlight the fact that we are using any. But if we are changing types, it would be even better to see if we can figure out more accurate types to use rather than defaulting to unknown.

True, true, true! I can dive into a couple of places and start investigating 🙂

@MajorLift
Copy link
Contributor

794 errors for @typescript-eslint/no-explicit-any are being reported in core as of today.

@Gudahtt
Copy link
Member

Gudahtt commented Dec 5, 2023

Looks like there are 162 errors on main today if you exclude test files and test utilities

@MajorLift
Copy link
Contributor

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

No branches or pull requests

5 participants