-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13900 from Microsoft/object-literal-freshness-wit…
…h-spread Object literal freshness errors with spreads
- Loading branch information
Showing
4 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/baselines/reference/objectLiteralFreshnessWithSpread.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
tests/cases/compiler/objectLiteralFreshnessWithSpread.ts(2,35): error TS2322: Type '{ z: number; b: number; extra: number; a: number; }' is not assignable to type '{ a: any; b: any; }'. | ||
Object literal may only specify known properties, and 'z' does not exist in type '{ a: any; b: any; }'. | ||
|
||
|
||
==== tests/cases/compiler/objectLiteralFreshnessWithSpread.ts (1 errors) ==== | ||
let x = { b: 1, extra: 2 } | ||
let xx: { a, b } = { a: 1, ...x, z: 3 } // error for 'z', no error for 'extra' | ||
~~~~ | ||
!!! error TS2322: Type '{ z: number; b: number; extra: number; a: number; }' is not assignable to type '{ a: any; b: any; }'. | ||
!!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ a: any; b: any; }'. | ||
|
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/objectLiteralFreshnessWithSpread.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//// [objectLiteralFreshnessWithSpread.ts] | ||
let x = { b: 1, extra: 2 } | ||
let xx: { a, b } = { a: 1, ...x, z: 3 } // error for 'z', no error for 'extra' | ||
|
||
|
||
//// [objectLiteralFreshnessWithSpread.js] | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
var x = { b: 1, extra: 2 }; | ||
var xx = __assign({ a: 1 }, x, { z: 3 }); // error for 'z', no error for 'extra' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
let x = { b: 1, extra: 2 } | ||
let xx: { a, b } = { a: 1, ...x, z: 3 } // error for 'z', no error for 'extra' |