Skip to content

Include arrow functions as javascript initializers #23068

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

Merged

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Apr 2, 2018

This means that they are treated as valid js containers, methods, etc. These kind of 'methods' are present in at least webpack and clear-require, even though they can't access this.

Fixes a variant of #22895
Fixes part of #22637

Note that recognising arrow functions as methods is good for understanding existing code, but bad in that it doesn't prevent JS authors from writing possibly buggy new code.

I think the right thing is to prefer understanding existing code, since we hope people will write new code in Typescript. They will, at least, have years of experience lowering their expectations of the correctness of any new Javascript that they write.

This means that they are treated as valid js containers, methods, etc.
@sandersn sandersn requested a review from mhegazy April 2, 2018 16:46
@sandersn sandersn merged commit 5c44241 into master Apr 2, 2018
@sandersn sandersn deleted the isMethodLike-recognises-arrows-as-js-prototype-methods branch April 2, 2018 17:11
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant