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
improve typing for unbound functions #1263
Conversation
This updates the creator APIs to more accurately express types for the returned function objects. For example, `match():` would be treated as a bound function relying on 'this', but it is now updated to `match: () =>`. This will not trigger the `@typescript-eslint/unbound-method` rule when passing `actions.act ionName.match`.
✔️ Deploy Preview for redux-starter-kit-docs ready! 🔨 Explore the source changes: 0b767e6 🔍 Inspect the deploy log: https://app.netlify.com/sites/redux-starter-kit-docs/deploys/60e62e1a3d335a00076738c4 😎 Browse the preview: https://deploy-preview-1263--redux-starter-kit-docs.netlify.app |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 0b767e6:
|
I'm still pretty much of the opinion that the ESLint authors do actually not understand how TypeScript works. This rule is not matching up with anything the language TypeScript does. It's a behaviour the rule authors have fabricated on top of TypeScript without any correlation to the language. Please check my comment here: There are differences between the two notations, but Quoting the TypeScript technical lead Ryan Cavanaugh: (also read the whole threads below)
Actually, introducing that bivariance here would from my understanding make the type system weaker here, not stronger. |
@phryneas after looking into it further, it seems like the preferred way of doing this would be the |
Honestly is is just insane that some ESLint author thinks they add additional meaning to a programming language and now unrelated upstream libraries have to conform to their weird interpretation to not hurt their users. 🙁 I gotta sleep over this, but right now I'm honestly not really happy about either of those changes. |
That's okay... I could be wrong on this, but the inability to augment the interface also prevents a local type definition from using the I'm not the best TypeScripter, but in |
Well, given that the changes themselves are innocent enough I'll go ahead and merge this in. I still don't agree with the reason for it and would rather see that ESLint rule deprecated (or at least adjusted, even though I don't see how that intent could reasonably be done in a correct way), but given my previous interactions with ESLint, I don't see that happening. And since I don't want to have this discussion again and again... Let's just get it in 😅 Thanks for the contribution - sorry for me being so grumpy 🙂 |
This updates the creator APIs to more accurately express types for the returned function objects. For example,
match():
would be treated as a bound function relying on 'this', but it is now updated tomatch: () =>
. This will not trigger the@typescript-eslint/unbound-method
rule when passingactions.act ionName.match
.