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
Object spread is fixed in the nightly build, as per #13878 last commented on 2 days ago, but Object.assign() is not fixed, and it doesn't seem to be mentioned in any existing issues.
TypeScript Version: 2.3.2, 2.4.0-dev.20170519
Code
interfaceLimited{property: string;}constassignment=(): Limited=>{return{property: 'this is fine'};};constassignment2=(): Limited=>{return{property: 'this is fine',property2: 'this is not fine, and shouldn\'t be',};};constnothing={};constsomethingElse={something: 'something'};constexisting={property: 'existing'};constassignment3=(): Limited=>{return{
...nothing,property2: 'this is not fine, and shouldn\'t be',};};constassignment4=(): Limited=>{return{
...somethingElse,property2: 'this is not fine, and shouldn\'t be',};};// - fails in 2.3.2 but not 2.4.0-dev.20170519constassignment5=(): Limited=>{return{
...existing,property2: 'this should not be fine, and is not in 2.4.0-dev.20170519',};};// !constassignment6=(): Limited=>{returnObject.assign(existing,{property2: 'this should not be fine either, but is',});};
Expected behavior:
Type guards should produce errors when attempting to assign a property not defined in the interface.
assignment5() and assignment6() should produce errors.
Actual behavior:
With Object.assign() or the Object spread operator, type guards fail to produce an error when attempting to assign a property not defined in the interface, as long as the required properties exist.
assignment5() and assignment6() does not produce an error.
The text was updated successfully, but these errors were encountered:
Object spread is fixed in the nightly build, as per #13878 last commented on 2 days ago, but Object.assign() is not fixed, and it doesn't seem to be mentioned in any existing issues.
#13878 is a different issue than what you are reporting.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Object spread is fixed in the nightly build, as per #13878 last commented on 2 days ago, but Object.assign() is not fixed, and it doesn't seem to be mentioned in any existing issues.
TypeScript Version: 2.3.2, 2.4.0-dev.20170519
Code
Expected behavior:
Type guards should produce errors when attempting to assign a property not defined in the interface.
assignment5() and assignment6() should produce errors.
Actual behavior:
With Object.assign()
or the Object spread operator, type guards fail to produce an error when attempting to assign a property not defined in the interface, as long as the required properties exist.assignment5() andassignment6() does not produce an error.The text was updated successfully, but these errors were encountered: