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

Safety of calling unbound methods #1327

Open
mightyiam opened this issue Nov 4, 2023 · 2 comments
Open

Safety of calling unbound methods #1327

mightyiam opened this issue Nov 4, 2023 · 2 comments

Comments

@mightyiam
Copy link
Owner

Apparently, TypeScript, even in strict mode, couldn't care less about the type of this while calling an unbound method.

The only way to enforce such safety is to enforce declaration of this in functions where this is used.

And yet, I don't see such a rule in typescript-eslint.

@mightyiam
Copy link
Owner Author

Another option is the [unbound-method](https://typescript-eslint.io/rules/unbound-method) lint rule. But it doesn't allow having unbound methods, which could be valid, albeit somewhat strange.

mightyiam added a commit that referenced this issue Nov 18, 2023
BREAKING CHANGE: add rule @typescript-eslint/unbound-method

Related to #1327

Co-authored-by: Rostislav Simonik <rostislav.simonik@technologystudio.sk>
standard-cd-bot bot pushed a commit that referenced this issue Nov 18, 2023
## [40.0.0](v39.1.1...v40.0.0) (2023-11-18)

### ⚠ BREAKING CHANGES

* add rule @typescript-eslint/unbound-method

### Features

* @typescript-eslint/unbound-method ([2ec6d24](2ec6d24)), closes [#1327](#1327)
@rostislav-simonik
Copy link
Collaborator

We have follow-up discussion on discord for no-unsafe-* check

And that would require also modification in unbound-method rule to exclude this: <with type>

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

No branches or pull requests

2 participants