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 extending native built-in classes in downlevel compilation #20723

Closed
justinfagnani opened this issue Dec 15, 2017 · 2 comments
Closed

Allow extending native built-in classes in downlevel compilation #20723

justinfagnani opened this issue Dec 15, 2017 · 2 comments
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@justinfagnani
Copy link

This has been covered in many closed issues, as far back as #1168, but there may be some new developments here that make a solution possible.

Babel has a PR in flight that enables extending native built-ins (including HTMLElement, which is my primary concern): babel/babel#7020

The technique is to wrap the native class with a class whose constructor calls Reflect.construct if it exists, ensuring that new.target is set properly. Babel's solution tries to statically detect if any extendable built-ins are subclassed in order to trigger wrapping them. It would also be useful to manually configure built-ins to wrap.

This at least lets downlevel output work properly on environments with extendable native classes. In environments without the extendable native classes, polyfills (like the Custom Elements polyfill) can possibly add them.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 10, 2018

Same request in #17825, #17088, and #15397

@mhegazy mhegazy added Suggestion An idea for TypeScript In Discussion Not yet reached consensus labels Jan 10, 2018
@RyanCavanaugh
Copy link
Member

There are very few remaining ES5-only runtimes and the workarounds are well-documented here, so we're not going to invest further in this area.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants