Search code examples
typescriptvisual-studio-2015taco

Enable Visual Studio Cordova Project support TypeScript EMCAScript 6


I want to use async / await feature of TypeScript in VS2015 Cordova project. I modify "target": "es6" in tsconfig.json

The intellisense doesn't show any error, however, while building the project, it shows:

Error TS1311 Build: Async functions are only available when targeting ECMAScript 6 and higher.

But I've already changed target to es6 in tsconfig.json

Where else should I config to make the build work?

Thanks.


Solution

  • tsconfig.json files were not picked up for certain project types. Work has been done on this for TypeScript 1.8, as you can read here:

    TypeScript 1.8 allows tsconfig.json files in all project types.

    If you you download the 1.8 beta from the announcement page (or wait for 1.8 proper), your tsconfig.json options should be respected.


    However, as you turn that functionality on, keep the following in mind:

    If you add a tsconfig.json file, TypeScript files that are not considered part of that context are not compiled.

    So you probably want to make sure that all your project's files are accounted for in your tsconfig.json, whether explicitly or by utilizing the "exclude" field.