Comments (6)
yeah I'm personally -1 on this given that the usecase of specifically passing an "external" function that accepts any
is rare.
This is also trivially worked-around from the user side (eg switching to an explicit arrow .catch((arg: unknown) => console.error(arg))
).
Now-a-days I think most 3rd-party things are going to accept unknown
instead of any
, and within your own codebase you can always switch the fn to unknown
.
it's either from an external library or will be flagged by --noImplicitAny/no-explicit-any
Assuming that you have that compiler option turned on or that you have that rule turned on.
It's not uncommon to not use the latter -- a lot of people don't love how restrictive it is.
from typescript-eslint.
Note: a related idea came up in the rule proposal, see #7526 (comment)
I personally don't have a strong opinion. Several points in favor and several points against spring to mind. We'll see what others say.
from typescript-eslint.
FWIW the only pain I had with adopting this rule is when I'm passing error-tracking utilities.
redisClient.connect().catch(winston.error);
redisClient.connect().catch(console.error);
redisClient.connect().catch(Sentry.captureException);
NONE OF THESE work.
So, I'm a big fan. If you are not implementing this function there's not much you can do anyway.
from typescript-eslint.
Having thought more thoroughly about this, I am +1 to the request as well. Passed in handlers will never have implicitly any
parameters, which is the real problem with supplying a function expression as a handler; the parameter doesn't require an annotation because it's deduced as any
from typescript-eslint.
I don't feel strongly enough about this to want to push back against multiple 👍s. I'll defer to the rest of the team's majority. 🙂
from typescript-eslint.
Kirk and I both hold the thought that this is fine:
function handler(x: any) {
// ...
}
Promise.reject().catch(handler);
It's still any
but it's explicit. If one turns off no-explicit-any
, I don't see why we should report this one but not any other blatantly unsafe things going on.
from typescript-eslint.
Related Issues (20)
- Bug: [no-unused-expressions] false negative on satisfies expression HOT 6
- Bug: Unconsistence behavior between cli and api call with vue-plugin HOT 1
- Bug: [strict-boolean-expressions] unsupported branded booleans HOT 1
- Bug: Return type of `tseslint.config()` is not compatible with eslint `Linter.FlatConfig[]`
- Docs: Add note of also trying major versions out on downstream ESLint plugins
- Rule proposal: functions should not be `async` unless they `await` HOT 15
- Enhancement: Add v8 projectService name to withoutProjectParserOptions HOT 1
- Enhancement: Remove getTokenAtPosition from type-utils
- Rule proposal: check that function is not returning promise and non-promise HOT 4
- Docs: Add generated documentation on packages exports to the site HOT 3
- Bug: TypeOrValueSpecifier should allow intersection types (no-floating-promises allowForKnownSafePromises)
- Bug: [prefer-optional-chain] conflict with [strict-boolean-expressions] HOT 3
- Document rationale for allowNumber: false in restrict-template-expressions HOT 3
- Bug: Vue + TypeScript project slowdown with v8 alpha HOT 9
- projectService / EXPERIMENTAL_useProjectService gives TS error if not boolean on v8 alpha / v7 HOT 1
- Docs: add an FAQ section about eslint TIMING/`--stats` and type-aware rules being misleading HOT 1
- Bug: `disabled-type-checked` config does not disable project service
- Enhancement: `no-misused-promises` should not flag functions whose contents are wrapped in `try`/`catch` HOT 2
- Base rule extension: nonblock-statement-body-position HOT 1
- Enhancement(typescript-estree): expose ProjectService logs through plugin HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-eslint.