You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceCar{doors: number;}constcar={doors: 4,}constcarCopy: Car={
...car,hp: 700,// would expect a type error here}console.log(carCopy);// {doors: 4, hp: 700}
Expected behavior:
When making a shallow copy of an object, where the resulting type is defined (via explicit typing, return type), I would expect unknown properties to be reported.
Actual behavior:
Compile error at mistyped/extraneous property.
This behaviour is consistent with Object.assign. Typescript will only complain about missing properties, but not of extraneous.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.4.0 (playground)
Code
Expected behavior:
When making a shallow copy of an object, where the resulting type is defined (via explicit typing, return type), I would expect unknown properties to be reported.
Actual behavior:
Compile error at mistyped/extraneous property.
This behaviour is consistent with
Object.assign
. Typescript will only complain about missing properties, but not of extraneous.The text was updated successfully, but these errors were encountered: