Promises not working on IE11

I'm new to Promises on javascript so I hope some can help me with this issue.

Problem: Promise not being execute on IE11, works fine on Chrome and FireFox

Frameworks used: I tried using es6-promise.d.ts and bluebird.d.ts same result.


static executeSomething(): Promise<any> 
  console.log("inside executeSomething");
  var test= new Promise((resolve, reject)=>
     console.log("inside Promise");

 console.log("after promise"); 
 return test;      

Results: on chrome and Firefox I can see all the logs but on IE11 I only see "Inside executeSomething" which means the problem is while creating the promise.

I thought it was because IE11 didn't support es6 but I get the same result using bluebird, I hope some can bring some light to my issue.

You need to include a promise polyfill in your page for IE11 to work.

Your instinct to use es-promise is correct, but you need to also include the .js file in your html

<script src="path/to/es6-promise.js"></script>

The .d.ts file will give the TypeScript compiler it's definitions, but does not affect runtime. You still need to include the polyfill in your html for it to actually run in the browser.

The biggest thing to remember when using TypeScript or any compiled language is the difference between compile time and run time.

.d.ts, .ts, .tsx, etc. Are all compile time files. Which means that these are not the files that are actually executed, but instead the files that generate the runtime code.

.js files are the runtime files. These are the files that are run by the browser.

.d.ts files do not contain code, but instead a definition of the code's signature and therefore should always be accompanied with a corresponding .js file that will run in the browser.