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
Rule proposal: enforce polymorphic this types #889
Comments
This rule should not be hard to implement (and should not require type checking) To implement this rule we should check all codepaths returns from method and validate if they return |
It's easy to find all return statements of a method and then validate. But not all codepath returns, how do we check if all codepath returns? @armano2 |
what's the status of this ? is anyone working in it? |
Nope, but I suspect that this isn't quite as simple as described. a
So simple code-path analysis won't work here. It will require type information, and be a decent chunk more complex to implement. As an aside - a good place to look for issues to work on would be this search which sorts issues by the number of reactions (a good metric for how "popular"/"needed" an issue is): |
I actually planned to crawl the definition for the function in this case as a recursive as that function might be returning something else or this class's instances.
on it 👍 |
The problem with crawling definitions is that you don't always have direct access to them - eg a method might exist on the parent. This will require type information to assess. |
yea agreed 💯 |
For those who may have not heard it, here's the doc.
The main point is that if a function always returns
this
, it should be typed asthis
explicitly or have implicitthis
type.Realworld example that breaks this rule:
https://github.com/BabylonJS/Babylon.js/blob/master/src/Meshes/transformNode.ts#L396
The text was updated successfully, but these errors were encountered: