Hi :)
EDIT:
As noted by Aluan Haddad (@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):
interfaceI<T>{f(): voidg(): void}consta={f<T>(this: I<T>): void{}}constb: I<any>=Object.assign({g(): void{}},a)Replacement for last 3 lines (compilation failing):
constb: 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; }'.
Hi :)
EDIT:
As noted by Aluan Haddad (@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):
Replacement for last 3 lines (compilation failing):
Expected behavior:
Replace
Object.assignwith the object spread operator should not be harmful.Actual behavior:
The first code makes happy the compiler.
However if I I replace
Object.assignwith the object spread operator (See replacement code), the compiler raises the next error: