Closed
Description
Hi :)
EDIT:
As noted by @aluanhaddad, the bug is related to the combination of the shorthand syntax in a literal object and the object spread operator on this object.
TypeScript Version: 2.1.4
Code
First code (compilation success):
interface I <T> {
f (): void
g (): void
}
const a = {
f <T> (this: I<T>): void {}
}
const b: I<any> = Object.assign({
g (): void {}
}, a)
Replacement for last 3 lines (compilation failing):
const b: I<any> = {
...a,
g (): void {}
}
Expected behavior:
Replace Object.assign
with the object spread operator should not be harmful.
Actual behavior:
The first code makes happy the compiler.
However if I I replace Object.assign
with the object spread operator (See replacement code), the compiler raises the next error:
error TS2322: Type '{ g(): void; }' is not assignable to type 'I<any>'.
Property 'f' is missing in type '{ g(): void; }'.