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
constf=(options: {foo?: number})=>{};leto: {foo?: number;bar?: string}={};f(o);// okf({ ...o});// error: bar does not exist in type { foo?: number }.f({ ...o,foo: 5});// same error. this is the use case.letp={ ...o};f(p);// okf(p={ ...o,foo: 5});// also ok
Expected behavior:
{...o} has the same type as o and should be interchangeable as function argument.
Probably won't be fixed until we have exact types, because people who don't want excess property errors currently have two workarounds (a [deprecated] compiler flag and extract-local), but people who do want excess property errors would have no way to cause them if this bug is fixed.
TypeScript Version: 2.9.1-insiders.20180525
Search Terms: argument rest spread object
Code
Expected behavior:
{...o}
has the same type aso
and should be interchangeable as function argument.Actual behavior:
Incorrect error is generated.
Playground Link:
Playground
Related Issues:
The text was updated successfully, but these errors were encountered: