Skip to content
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

Allow decorators in ES3 #4741

Merged
merged 4 commits into from
Oct 2, 2015
Merged

Allow decorators in ES3 #4741

merged 4 commits into from
Oct 2, 2015

Conversation

rbuckton
Copy link
Member

This change modifies the checker and the emitter to support the use of decorators when targeting ES3. In addition to removing the ES5-specific use of reduceRight from the __decorate helper, this change also inlines the calls to Object.getOwnPropertyDescriptor and Object.defineProperty in a backwards-compatible fashion that allows us to clean up the emit for ES5 and later by removing various repetitive calls to the aforementioned Object methods.

Addresses #4681.

@DanielRosenwasser
Copy link
Member

I'm not sure if I'm okay with dropping the error message - I think that decorators that won't properly work in ES3 should get an error.

@rbuckton
Copy link
Member Author

@DanielRosenwasser Are you talking about a specific error? Part of this change is to have the emit for method decorators in ES3 not include the property descriptor, just as with decorators on property declarations.

@mhegazy
Copy link
Contributor

mhegazy commented Sep 11, 2015

but this will have a different behavior for ES3/ES5 for method decorators with no errors.

@DanielRosenwasser
Copy link
Member

Yes, if method decorators won't work properly, then you should warn users that method decorators are only supported in ES5 or higher.

@rbuckton
Copy link
Member Author

@DanielRosenwasser, In this change method decorators will work in the same way that decorators for property declarations work. No descriptor will be provided nor accepted. There will be no error.

@rbuckton
Copy link
Member Author

rbuckton commented Oct 2, 2015

@DanielRosenwasser, @mhegazy Any further concerns/discussion with this PR?

@mhegazy
Copy link
Contributor

mhegazy commented Oct 2, 2015

👍
I am still not sure about the error though

@rbuckton
Copy link
Member Author

rbuckton commented Oct 2, 2015

The error that I removed no longer applies. The only difference between decorators in ES3 and ES5 is that ES3 decorators cannot take and don't observe a descriptor.

@DanielRosenwasser
Copy link
Member

@rbuckton I'll need to ask a few questions about this offline.

rbuckton added a commit that referenced this pull request Oct 2, 2015
@rbuckton rbuckton merged commit 331d26f into master Oct 2, 2015
@rbuckton rbuckton deleted the es3Decorators branch October 2, 2015 23:22
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
4 participants