-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Private field can't be called as a function #7877
Labels
Comments
Good find, I'm working on a fix to this now. |
rk-for-zulip
added a commit
to rk-for-zulip/zulip-mobile
that referenced
this issue
Dec 12, 2019
The TC39 class fields proposal [1] -- stage 3, but already implemented and available in Chrome 74 -- allows for truly private member variables. This feature has also been supported by Babel since at least version 7.3. Alas, the intersection of private fields and *Flow* is a much more poorly-supported area. There are several known issues: * prettier/prettier#5288 * babel/babel-eslint#688 * facebook/flow#7877 A workaround exists for the first one (Babel is now usable as the parser), but not the latter two. As an approximation, then, we allow leading underscores in property names until this feature is available. [1]: https://github.com/tc39/proposal-class-fields
gnprice
pushed a commit
to rk-for-zulip/zulip-mobile
that referenced
this issue
Dec 13, 2019
The TC39 class fields proposal [1] -- stage 3, but already implemented and available in Chrome 74 -- allows for truly private member variables. This feature has also been supported by Babel since at least version 7.3. Alas, the intersection of private fields and *Flow* is a much more poorly-supported area. There are several known issues: * prettier/prettier#5288 * babel/babel-eslint#688 * facebook/flow#7877 A workaround exists for the first one (Babel is now usable as the parser), but not the latter two. As an approximation, then, we allow leading underscores in property names until this feature is available. [1]: https://github.com/tc39/proposal-class-fields
Any news? |
As a temporary solution, do this:
instead of:
|
Still not work. |
facebook-github-bot
pushed a commit
that referenced
this issue
Aug 17, 2021
Summary: This diff adds support for type checking private methods. I added private methods and private static methods into the same class entries that stores type signature of private fields, and then use these type signature information to resolve `GetPrivatePropT` and `PrivateMethodT`. I also ensured that unbinding private methods are also correctly errored on, similar to unbound public methods. Fixes #6254 #4872 #7877. Reviewed By: jbrown215 Differential Revision: D30023778 fbshipit-source-id: 5575306de4ac504a92fb8bba221221566b5ac52d
facebook-github-bot
pushed a commit
that referenced
this issue
Aug 18, 2021
Summary: This diff adds support for type checking private methods. I added private methods and private static methods into the same class entries that stores type signature of private fields, and then use these type signature information to resolve `GetPrivatePropT` and `PrivateMethodT`. I also ensured that unbinding private methods are also correctly errored on, similar to unbound public methods. Fixes #6254 #4872 #7877. Reviewed By: jbrown215 Differential Revision: D30023778 fbshipit-source-id: 71fae1a81d9b373f18b9ec4743380e846564a49f
This has been fixed in version 0.158.0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Flow version: 0.102.0
Expected behavior
The following should typecheck without errors.
Actual behavior
Flow gives an error
Changing the call site to
works as expected.
Issue #6254 is related, but seems to be more about defining private methods, which is a separate ES proposal. This issue is more about using private fields that can already be defined just fine.
https://flow.org/try/#0C4TwDgpgBAYgdlAvFAFASiQPigQziAKAIGMAbHAZwqgEEoBvAqKAYgDMB7DgLlgWXRYoAFgBMTKMRylSMLoMbNmwABYBLCgDp28tBIC+BfUA.
The text was updated successfully, but these errors were encountered: