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
Overloding methods in class without declare
#2260
Comments
See intersection types example:
It should work outside of declarations too. |
Right. But how do I use this inside |
Just to clarify: you've made function |
@rpominov ah... right, not sure how it fits with method types declarations. But the case you described can be typed with:
right? |
@rpominov disregard my last response, you have a dependency between args. Waiting for some smarter one to answer that then. |
Not quite same thing. In your version But anyway, this is not my real case. I need this for a static method similar to |
I don't think it's possible. The easiest way around is to have a separate declaration and cast implementation to declaration type via |
That is an option. But will I have to duplicate all other methods in declaration and in implementation then? |
Yes, I think that's the only option without affecting runtime behaviour |
Seems like a room for improvement for Flow then. There should be a way to do this somehow without duplication. |
The problem is, it's hard to check for Flow that a method body satisfies multiple signatures. Which is why we implemented it for This should be fixed. |
Using
declare
we can overload methods in classes:But is it possible without
declare
?Here is a not working example just to illustrate what I mean:
The text was updated successfully, but these errors were encountered: