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

Vague error message with async functions #11396

Description

async function foo() {
    return "hi";
}

First thing I get is An async function must have a valid awaitable return type.

From a UX perspective, this is very confusing. If you add es2015.promise to your lib, it goes away.

Activity

  1. normalser commented on Oct 5, 2016

    @normalser

    Yea, I got confused by this in the past #10805
    Especially that in one project it worked fine (that used older types for Bluebird) and in new project with latest Bluebird typings (which stopped exporting global definition for Promise) it was throwing this error with example taken from docs. Some more info for users in this error would be beneficial.

    and if you do import * as Promise from 'bluebird' - you get error TS2529: Duplicate identifier 'Promise'. Compiler reserves name 'Promise' in top level scope of a module containing async functions

    so not too clear for users

  2. blvd20 commented on Oct 21, 2016

    @blvd20

    Is there another way to solve this problem now?

  3. modified the milestones: TypeScript 2.1, on Oct 27, 2016
  4. added a commit that references this issue on Nov 1, 2016
  5. added a commit that references this issue on Nov 2, 2016
    6b94bae
  6. added
    FixedA PR has been merged for this issue
    and removed on Nov 2, 2016
  7. added a commit that references this issue on Nov 10, 2016
    245a998
  8. 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

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