-
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.
Don't include class getter in spread type
Andy Hanson
committed
Aug 8, 2018
1 parent
1a05f13
commit 7dded40
Showing
7 changed files
with
282 additions
and
140 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
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
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 |
---|---|---|
@@ -1,33 +1,56 @@ | ||
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(16,4): error TS2339: Property 'm' does not exist on type '{ p: number; }'. | ||
tests/cases/conformance/types/spread/spreadMethods.ts(17,4): error TS2339: Property 'g' does not exist on type '{ p: number; }'. | ||
tests/cases/conformance/types/spread/spreadMethods.ts(19,5): error TS2339: Property 'm' does not exist on type '{ p: number; }'. | ||
tests/cases/conformance/types/spread/spreadMethods.ts(20,5): error TS2339: Property 'g' 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 } | ||
==== tests/cases/conformance/types/spread/spreadMethods.ts (4 errors) ==== | ||
class K { | ||
p = 12; | ||
m() { } | ||
get g() { return 0; } | ||
} | ||
interface I { | ||
p: number; | ||
m(): void; | ||
readonly g: number; | ||
} | ||
|
||
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; }'. | ||
sk.g; // error | ||
~ | ||
!!! error TS2339: Property 'g' 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() { } }; | ||
ssk.g; // error | ||
~ | ||
!!! error TS2339: Property 'g' does not exist on type '{ p: number; }'. | ||
|
||
let i: I = { p: 12, m() { }, get g() { return 0; } }; | ||
let si = { ...i }; | ||
let ssi = { ...i, ...i }; | ||
si.p; | ||
si.m(); // ok | ||
si.g; // ok | ||
ssi.p; | ||
ssi.m(); // ok | ||
let o = { p: 12, m() { } }; | ||
ssi.g; // ok | ||
|
||
let o = { p: 12, m() { }, get g() { return 0; } }; | ||
let so = { ...o }; | ||
let sso = { ...o, ...o }; | ||
so.p; | ||
so.m(); // ok | ||
so.g; // ok | ||
sso.p; | ||
sso.m(); // ok | ||
sso.g; // ok | ||
|
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 |
---|---|---|
@@ -1,66 +1,78 @@ | ||
//// [spreadMethods.ts] | ||
class K { p = 12; m() { } } | ||
interface I { p: number, m(): void } | ||
class K { | ||
p = 12; | ||
m() { } | ||
get g() { return 0; } | ||
} | ||
interface I { | ||
p: number; | ||
m(): void; | ||
readonly g: number; | ||
} | ||
|
||
let k = new K() | ||
let sk = { ...k }; | ||
let ssk = { ...k, ...k }; | ||
sk.p; | ||
sk.m(); // error | ||
sk.g; // error | ||
ssk.p; | ||
ssk.m(); // error | ||
let i: I = { p: 12, m() { } }; | ||
ssk.g; // error | ||
|
||
let i: I = { p: 12, m() { }, get g() { return 0; } }; | ||
let si = { ...i }; | ||
let ssi = { ...i, ...i }; | ||
si.p; | ||
si.m(); // ok | ||
si.g; // ok | ||
ssi.p; | ||
ssi.m(); // ok | ||
let o = { p: 12, m() { } }; | ||
ssi.g; // ok | ||
|
||
let o = { p: 12, m() { }, get g() { return 0; } }; | ||
let so = { ...o }; | ||
let sso = { ...o, ...o }; | ||
so.p; | ||
so.m(); // ok | ||
so.g; // ok | ||
sso.p; | ||
sso.m(); // ok | ||
sso.g; // ok | ||
|
||
|
||
//// [spreadMethods.js] | ||
var __assign = (this && this.__assign) || function () { | ||
__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; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var K = /** @class */ (function () { | ||
function K() { | ||
class K { | ||
constructor() { | ||
this.p = 12; | ||
} | ||
K.prototype.m = function () { }; | ||
return K; | ||
}()); | ||
var k = new K(); | ||
var sk = __assign({}, k); | ||
var ssk = __assign({}, k, k); | ||
m() { } | ||
get g() { return 0; } | ||
} | ||
let k = new K(); | ||
let sk = { ...k }; | ||
let ssk = { ...k, ...k }; | ||
sk.p; | ||
sk.m(); // error | ||
sk.g; // error | ||
ssk.p; | ||
ssk.m(); // error | ||
var i = { p: 12, m: function () { } }; | ||
var si = __assign({}, i); | ||
var ssi = __assign({}, i, i); | ||
ssk.g; // error | ||
let i = { p: 12, m() { }, get g() { return 0; } }; | ||
let si = { ...i }; | ||
let ssi = { ...i, ...i }; | ||
si.p; | ||
si.m(); // ok | ||
si.g; // ok | ||
ssi.p; | ||
ssi.m(); // ok | ||
var o = { p: 12, m: function () { } }; | ||
var so = __assign({}, o); | ||
var sso = __assign({}, o, o); | ||
ssi.g; // ok | ||
let o = { p: 12, m() { }, get g() { return 0; } }; | ||
let so = { ...o }; | ||
let sso = { ...o, ...o }; | ||
so.p; | ||
so.m(); // ok | ||
so.g; // ok | ||
sso.p; | ||
sso.m(); // ok | ||
sso.g; // ok |
Oops, something went wrong.