Skip to content

Async Await not working on node 6, typescript@beta or typescript@next despite target = es6 #10584

@dcworldwide

Description

@dcworldwide

I can't use async await in my codebase. TSC throws 'error TS1311: Async functions are only available when targeting ECMAScript 2015 or higher'

TypeScript Version: 2@beta and 2.1.0-dev.20160829

Code

var p = function() {
    return new Promise<string>((resolve, reject) => {
        resolve("test")
    })
}

let caller = async function () {
    let s = await p()
}

caller()

tsconfig.json

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "removeComments": true,
    "outDir": "./lib",
    "allowJs": true,
    "pretty": true,
    "experimentalDecorators": true,
    "noImplicitAny": false, // Raise error on expressions and declarations with an implied ‘any’ type.
    "forceConsistentCasingInFileNames": true, // Disallow inconsistently-cased references to the same file.
    "preserveConstEnums": true //Do not erase const enum declarations in generated code.
  },
//  "include": [
//    "./src/public/*"
//  ],
  "exclude": [
    "node_modules"
  ]
}

Running "prepublish": "tsc --outDir ./lib src/index.ts", from my package.json.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions