Skip to content

type alias is not inferred in async functions #32681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fogfish opened this issue Aug 2, 2019 · 2 comments
Closed

type alias is not inferred in async functions #32681

fogfish opened this issue Aug 2, 2019 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@fogfish
Copy link

fogfish commented Aug 2, 2019

TypeScript Version: 3.5.3

Search Terms: promise, async function, return type in ES5/ES3

Code

type Response = {statusCode: number, body: string}
type IO = Promise<Response>

export async function main(): IO {
  return Promise.resolve({statusCode: 200, body: "ok"})
}

Expected behavior:
Successful compilation

Actual behavior:

error TS1055: Type 'IO' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.

4 export async function main(): IO {
// tsconfig.json
{
  "compilerOptions": {
    "target":"ES2018",
    "module": "commonjs",
    "lib": ["es2016", "es2017.object", "es2017.string", "dom"],
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": false,
    "inlineSourceMap": true,
    "inlineSources": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization":false
  }
}

Playground Link:
Unable to reproduce in playground

Related Issues:
No

@MartinJohns
Copy link
Contributor

Duplicate of #32574.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Aug 2, 2019
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants