javascript - Promises not working on IE11 -


i'm new promises on javascript hope can me issue.

problem: promise not being execute on ie11, works fine on chrome , firefox

frameworks used: tried using es6-promise.d.ts , bluebird.d.ts same result.

code:

static executesomething(): promise<any>  {   console.log("inside executesomething");   var test= new promise((resolve, reject)=>   {      console.log("inside promise");    }).catch(function(error){console.log("error")});   console.log("after promise");   return test;       } 

results: on chrome , firefox can see logs on ie11 see "inside executesomething" means problem while creating promise.

i thought because ie11 didn't support es6 same result using bluebird, hope can bring light issue.

you need include promise polyfill in page ie11 work.

your instinct use es-promise correct, need include .js file in html

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

the .d.ts file give typescript compiler it's definitions, not affect runtime. still need include polyfill in html run in browser.

the biggest thing remember when using typescript or compiled language difference between compile time , run time.

.d.ts, .ts, .tsx, etc. compile time files. means these not files executed, instead files generate runtime code.

.js files runtime files. these files run browser.

.d.ts files not contain code, instead definition of code's signature , therefore should always accompanied corresponding .js file run in browser.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -