-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Support Automatically bind this
in Compiler Options
#19214
Comments
this
in Compiler Optionsthis
in Compiler Options
See #3927, others. Instead of writing awkward |
But I heard that arrow function evaluate non-perfomant specially when being used in react render function.. I hope I made my point correct |
Beside that I can't use call super for your suggestion when using inhirtance |
Yeah, writing every method as an arrow function might be a bad idea. You might be interested in the no-unbound-method lint rule. That makes you perform the bind at the use rather than at the definition. |
This would also be the case if you automatically In general you should only be having to use arrow functions in a few very specific places. Most JS libraries will give you the correct Either way, we don't change the behavior of existing JS code, so this isn't an option we'll be adding. |
Thanks @RyanCavanaugh 👍 |
Expected behavior:
this
keyword in render always will point to Test class instance without the need to write .bind line for each function (Specially for React.js developers), andthis
in OOO always is the class instance, and being not is anti-pattern.Actual behavior:
bind is not always, you need to write something like this for every function:
I heard from someone that you don't want to do this to be back-compatible with JavaScript, so I hope you insert it into a new compilerConfiguration entry (default is false also 😆 I don't mind)
Thanks for your great contribution. I love you all ❤️
The text was updated successfully, but these errors were encountered: