-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Allow decorators in ES3 #4741
Conversation
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. |
@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. |
but this will have a different behavior for ES3/ES5 for method decorators with no errors. |
Yes, if method decorators won't work properly, then you should warn users that method decorators are only supported in ES5 or higher. |
@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. |
@DanielRosenwasser, @mhegazy Any further concerns/discussion with this PR? |
👍 |
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. |
@rbuckton I'll need to ask a few questions about this offline. |
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 toObject.getOwnPropertyDescriptor
andObject.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 aforementionedObject
methods.Addresses #4681.