-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
--target ES5 does not compile ES5-compatible code (String.prototype.repeat) when libs are used #25853
Comments
#3101 already contains a discussion around not polyfilling and I don't think much has changed since then. |
@DanielRosenwasser thanks for quick response. I mentioned the issue #3101 because it's the most relevant that I could find and auto-polyfilling would probably resolve the issue. Let's face the fact:
If a user provides custom If auto-polyfilling is not an option, documenting the caveat properly or printing a warning or somehow preventing user from doing the mistake and investigating would make the job. P.S. |
Async/await is syntax that cannot be polyfilled because older javascript VMs cannot parse it. |
And while I agree it is a pain-point, I still think that bring-your-own-polyfill has worked reasonably well for the most part. |
Maybe the correct wording should be "ES5 compatible syntax"? |
If the dev team considers this as not an issue please close it, I still think it is misguiding and error-prone :) Thank you guys for your time! |
From the moment you added My opinion: this is by design. |
I have seen tag "design limitation" assigned to some issues - probably that's the proper tag for this one as well? I actually see quite a nice description of and it mentions assuming runtime support of included declarations. |
Hi, I am a facing an issue related to that problem. I was using TS 2.7.2 + core-js with ES5 target ES6 lib, and wanted to update to 3.1. Before it was generating proper ES5 code but now it produces ES6 code and some of this code is not being polyfilled by core-js, typically the property value shorthand like {pos} instead of {pos: pos}. What are the options to generate proper ES5 code ? |
TypeScript Version: Version 2.9.2
Search Terms:
es5 string.prototype.repeat
Code
tsconfig.json
Expected behavior:
Expecting
String.prototype.repeat
to be polyfilled or rewritten in the same manner thatasync/await
syntax in transpiled correctly because the target ises5
andString.prototype.repeat
is not part of ES5.That is according to documentation
Actual behavior:
The expression appears as is
Playground Link:
https://github.com/agoldis/typescript-25853
Related Issues:
#3101
The text was updated successfully, but these errors were encountered: