2

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?

2
  • 2
    On further investigation, looks like ionic 2 locks in es5 as the target to prevent errors in Angular. Until Typescript 2.1 comes out, seems like async / await are off the table (react-etc.net/entry/…). Commented Oct 13, 2016 at 22:21
  • Please mark answer accepted Commented Feb 6, 2018 at 0:54

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Is this still the case?
You wont encounter said problem anymore. Later versions enabled smooth usage

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.