Test method removal of object spread
Test that 1. Only class methods get removed 2. Methods from both left and right get removed.
This commit is contained in:
parent
876dbe86ee
commit
309a361b19
3 changed files with 119 additions and 0 deletions
33
tests/baselines/reference/spreadMethods.errors.txt
Normal file
33
tests/baselines/reference/spreadMethods.errors.txt
Normal file
|
@ -0,0 +1,33 @@
|
|||
tests/cases/conformance/types/spread/spreadMethods.ts(7,4): error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
tests/cases/conformance/types/spread/spreadMethods.ts(9,5): error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/spread/spreadMethods.ts (2 errors) ====
|
||||
class K { p = 12; m() { } }
|
||||
interface I { p: number, m(): void }
|
||||
let k = new K()
|
||||
let sk = { ...k };
|
||||
let ssk = { ...k, ...k };
|
||||
sk.p;
|
||||
sk.m(); // error
|
||||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
ssk.p;
|
||||
ssk.m(); // error
|
||||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
let i: I = { p: 12, m() { } };
|
||||
let si = { ...i };
|
||||
let ssi = { ...i, ...i };
|
||||
si.p;
|
||||
si.m(); // ok
|
||||
ssi.p;
|
||||
ssi.m(); // ok
|
||||
let o = { p: 12, m() { } };
|
||||
let so = { ...o };
|
||||
let sso = { ...o, ...o };
|
||||
so.p;
|
||||
so.m(); // ok
|
||||
sso.p;
|
||||
sso.m(); // ok
|
||||
|
63
tests/baselines/reference/spreadMethods.js
Normal file
63
tests/baselines/reference/spreadMethods.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
//// [spreadMethods.ts]
|
||||
class K { p = 12; m() { } }
|
||||
interface I { p: number, m(): void }
|
||||
let k = new K()
|
||||
let sk = { ...k };
|
||||
let ssk = { ...k, ...k };
|
||||
sk.p;
|
||||
sk.m(); // error
|
||||
ssk.p;
|
||||
ssk.m(); // error
|
||||
let i: I = { p: 12, m() { } };
|
||||
let si = { ...i };
|
||||
let ssi = { ...i, ...i };
|
||||
si.p;
|
||||
si.m(); // ok
|
||||
ssi.p;
|
||||
ssi.m(); // ok
|
||||
let o = { p: 12, m() { } };
|
||||
let so = { ...o };
|
||||
let sso = { ...o, ...o };
|
||||
so.p;
|
||||
so.m(); // ok
|
||||
sso.p;
|
||||
sso.m(); // ok
|
||||
|
||||
|
||||
//// [spreadMethods.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 K = (function () {
|
||||
function K() {
|
||||
this.p = 12;
|
||||
}
|
||||
K.prototype.m = function () { };
|
||||
return K;
|
||||
}());
|
||||
var k = new K();
|
||||
var sk = __assign({}, k);
|
||||
var ssk = __assign({}, k, k);
|
||||
sk.p;
|
||||
sk.m(); // error
|
||||
ssk.p;
|
||||
ssk.m(); // error
|
||||
var i = { p: 12, m: function () { } };
|
||||
var si = __assign({}, i);
|
||||
var ssi = __assign({}, i, i);
|
||||
si.p;
|
||||
si.m(); // ok
|
||||
ssi.p;
|
||||
ssi.m(); // ok
|
||||
var o = { p: 12, m: function () { } };
|
||||
var so = __assign({}, o);
|
||||
var sso = __assign({}, o, o);
|
||||
so.p;
|
||||
so.m(); // ok
|
||||
sso.p;
|
||||
sso.m(); // ok
|
23
tests/cases/conformance/types/spread/spreadMethods.ts
Normal file
23
tests/cases/conformance/types/spread/spreadMethods.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
class K { p = 12; m() { } }
|
||||
interface I { p: number, m(): void }
|
||||
let k = new K()
|
||||
let sk = { ...k };
|
||||
let ssk = { ...k, ...k };
|
||||
sk.p;
|
||||
sk.m(); // error
|
||||
ssk.p;
|
||||
ssk.m(); // error
|
||||
let i: I = { p: 12, m() { } };
|
||||
let si = { ...i };
|
||||
let ssi = { ...i, ...i };
|
||||
si.p;
|
||||
si.m(); // ok
|
||||
ssi.p;
|
||||
ssi.m(); // ok
|
||||
let o = { p: 12, m() { } };
|
||||
let so = { ...o };
|
||||
let sso = { ...o, ...o };
|
||||
so.p;
|
||||
so.m(); // ok
|
||||
sso.p;
|
||||
sso.m(); // ok
|
Loading…
Reference in a new issue