kenzie
kenzie

Reputation: 217

Promise on older versions of javascript

I am currently working with typescript and the new ECMAscript 6 feature Promise. My question is, can I use the Promise feature if my TypeScript gets compiled to a f.e. ECMAscript 3 js-file? I mean the Promise wasn't implemented at this version.

Upvotes: 1

Views: 420

Answers (1)

mvermand
mvermand

Reputation: 6117

You can use a polyfill:

https://www.npmjs.com/package/es6-promise-polyfill

To install:

bower install es6-promise-polyfill

To use:

<script src="bower_components/es6-promise-polyfill/promise.min.js"></script>
<script>
  var promise = new Promise(...);
</script>

Upvotes: 2

Related Questions