Reputation: 3349
When I make a new Ionic --v2 project and use an async function
declaration, ionic build browser
fails with:
db.ts:15:16: Async functions are only available when targeting ECMAScript 2015 or higher.
I would have thought that changing tsconfig.json
's target
to es6
would fix the problem, but it did not. What can I do to resolve this so that I can use async/await
in my Ionic projects?
Upvotes: 2
Views: 687
Reputation: 5706
Es6 works if you choose your module to be es2015 and not commonjs.
This will of course hinder your support of some mobile devices because not all of them support es6 especially safari so you'll have to babel your code which will add a hefty weight on it.
If you wish you could remain at es5 and specify typescript 2.1 in your package.json. This will prevent you from using aot or prod configuration sadly but otherwise it works.
With angular v4 coming out hopefully someone will update app scripts to support 2.1.
Upvotes: 1