-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
"'Promise' is undefined" error in IE11 even though targeting ES5 #14308
Comments
The runtime has to support
|
@gcnew, Thanks for the quick response. I had read that note in the docs, but I didn't really "get it" at the time. Now that I've experienced it, it makes sense. Anyway, it's a little confusing to me what exactly it means when I put An interesting counter-example to So, I'm not seeing a clear rule of thumb on when the typescript compiler will polyfill something and when it won't. I think it would be very helpful to developers if all ES6 language features and types were polyfilled when specifying |
It is possible to emit perfectly fine However, it would be nice to have a way of forbidding the compiler from emitting code that may require certain polyfills; maybe throwing a syntax error about forbidden syntax, similar to how TypeScript complains about |
@Kovensky Doesn't the |
@devuxer Are you sure you environment doesn't support |
The |
@Kovensky Exactly. You were asking for something that:
That's the compilers goal. It would error if you didn't include the |
Note that not everything is polyfillable; you may also be working with a partial implementation. For ES5, say, Though I guess that, in this case, it could work to have the compiler refuse to accept |
One idea is when hook is available, a tool may be created alongside tsc to install the polyfills you need for the specific target. 🌷 |
Absolutely. I think in the ideal world the type information would possibly block the impossible things, but I also realise it's pretty improbable to build that out since most people will pick up the default Yeah, in the
That could be a nice idea. Combine that with browser statistics information should be pretty easy too so that only the polyfills on each supported environment are included. |
Well, the issue has been closed, but I haven't really found the answer to the question here :( |
The answer for me has been to visit polyfill.io anytime I get a runtime error in IE11. The error almost always gives a hint as to what feature is missing, and polyfill.io almost always has a polyfill for it. |
@devuxer Thanks for the summary, it's really helpful! |
When jsconfig.json target is 'es5' and lib has 'es6' following should 'fix' all IE11 polyfills: <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=es6"></script> |
@nsteenbeek Thanks for the solution. Helped me out. |
I need solution where I have no access to polyfill.io (no internet access) |
@nsteenbeek If ever meet you in person i'm gonna give you a large hug and buy you a beer, your solution helped me out. |
TypeScript Version: 2.1.1
Code
tsconfig.json
ajax.ts
index.tsx
index.html
Expected behavior
Promise
is replaced with callbacks, etc. to be compatible with ES5.Actual behavior
SCRIPT5009: 'Promise' is undefined
.The text was updated successfully, but these errors were encountered: