FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow decorators in ES3 by rbuckton · Pull Request #4741 · microsoft/TypeScript · GitHub

Allow decorators in ES3 - #4741

Merged
Ron Buckton (rbuckton) merged 4 commits into
masterfrom
es3Decorators
Oct 2, 2015
Merged

Allow decorators in ES3#4741
Ron Buckton (rbuckton) merged 4 commits into
masterfrom
es3Decorators

Conversation

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
Contributor Author

Daniel Rosenwasser (@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.

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

Daniel Rosenwasser (@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.

Copy link
Copy Markdown
Contributor Author

Daniel Rosenwasser (@DanielRosenwasser), Mohamed Hegazy (@mhegazy) Any further concerns/discussion with this PR?

Copy link
Copy Markdown
Contributor

👍
I am still not sure about the error though

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

Ron Buckton (@rbuckton) I'll need to ask a few questions about this offline.

Ron Buckton (rbuckton) added a commit that referenced this pull request Oct 2, 2015
Ron Buckton (rbuckton) merged commit 331d26f into master Oct 2, 2015
Ron Buckton (rbuckton) deleted the es3Decorators branch October 2, 2015 23:22
Microsoft (microsoft) locked and limited conversation to collaborators Jun 19, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

4 participants


Back | FazBrowse Home | New Git URL