Skip to content

Inconsistency in types returned by Object.assign #13912

New issue

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

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

Already on GitHub? # to your account

Closed
bjouhier opened this issue Feb 6, 2017 · 2 comments
Closed

Inconsistency in types returned by Object.assign #13912

bjouhier opened this issue Feb 6, 2017 · 2 comments

Comments

@bjouhier
Copy link

bjouhier commented Feb 6, 2017

TypeScript Version: 2.1.5

Code

const foo = Object.assign({}, {
    f() { return 1; }
});
// next line does not give error because foo is typed as any :-(
foo.g();

const bar = {
    f() { return 1; }
}
const zoo = Object.assign({}, bar);
// but next line does give error :-)
zoo.h();

Expected behavior:
foo.ts(5,5): error TS2339: Property 'g' does not exist on type '{} & { f(): number; }'.
foo.ts(12,5): error TS2339: Property 'h' does not exist on type '{} & { f(): number; }'.

Actual behavior:
foo.ts(12,5): error TS2339: Property 'h' does not exist on type '{} & { f(): number; }'.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 6, 2017

Though not the same issue, but should be covered by #11100

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label May 24, 2017
@RyanCavanaugh RyanCavanaugh removed the Needs Investigation This issue needs a team member to investigate its status. label Sep 18, 2019
@RyanCavanaugh
Copy link
Member

This has been fixed

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants