镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Compiler allows async function expressions in ES3/ES5 #7334

Description

@yortus

TypeScript Version:

1.8

Code

// file: index.ts
declare class Promise<T> {/***/}
async function foo() { return 42; } // ERROR: Async functions are only available in ES6+
let bar = async function () { return 42; } // OK, but should be an error
let baz = async () => 42; // OK, but should be an error

// file: tsconfig.json
{
    "compilerOptions": {
        "target": "es5"
    }
}

Expected behavior:
The bar and baz lines should also get error TS1311 'Async functions are only available in ES6 or higher'.

Actual behavior:
The bar and baz lines compile without errors.

Activity

  1. zpdDG4gta8XKpMCd commented on Jun 7, 2016

    @zpdDG4gta8XKpMCd

    #8581 might me related

  2. zpdDG4gta8XKpMCd commented on Jun 7, 2016

    @zpdDG4gta8XKpMCd

    also might relate: #8584

  3. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions