Skip to content
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

Object literal in async function should only specify known properties #12423

Closed
ghost opened this issue Nov 21, 2016 · 3 comments
Closed

Object literal in async function should only specify known properties #12423

ghost opened this issue Nov 21, 2016 · 3 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@ghost
Copy link

ghost commented Nov 21, 2016

TypeScript Version: nightly (2.2.0-dev.20161121 )

Code

function foo(): { x: number } {
    return { x: 1, y: 2 };
}

async function bar(): Promise<{ x: number }> {
    return { x: 1, y: 2 };
}

Expected behavior:

Both are errors.

Actual behavior:

Only the first is an error.

@yortus
Copy link
Contributor

yortus commented Nov 22, 2016

A third variant that currently gives no errors:

function baz(): Promise<{ x: number }> {
    return Promise.resolve({ x: 1, y: 2 });
}

That's semantically identical to bar. So if bar should be an error, what about baz?

@mhegazy
Copy link
Contributor

mhegazy commented Nov 22, 2016

the last one is not related. the last one is about using the return type as an inference location, see #11152

@mhegazy mhegazy added the Bug A bug in TypeScript label Nov 22, 2016
@mhegazy mhegazy added this to the Future milestone Nov 22, 2016
@sandersn sandersn removed their assignment Jan 7, 2020
@Andarist
Copy link
Contributor

Andarist commented Jan 8, 2023

This one works OK today, so the issue could be closed :) cc @RyanCavanaugh

@sandersn sandersn closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants