Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 13734e7

Browse filesBrowse files
Fix for issue microsoft#6154 - overriding methods with properties in the derived class (microsoft#24343)
* Fix to issue 6154 - Overriding a method with a property in the derived class should not cause a compiler error * new baselines * fixed deleted baselines
1 parent 9b9ec63 commit 13734e7
Copy full SHA for 13734e7

12 files changed

+101-93Lines changed: 101 additions & 93 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24489,7 +24489,7 @@ namespace ts {
2448924489
continue;
2449024490
}
2449124491

24492-
if (isPrototypeProperty(base) && isPrototypeProperty(derived) || base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) {
24492+
if (isPrototypeProperty(base) || base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) {
2449324493
// method is overridden with method or property/accessor is overridden with property/accessor - correct case
2449424494
continue;
2449524495
}
Collapse file

‎tests/baselines/reference/checkJsFiles_noErrorLocation.errors.txt‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/checkJsFiles_noErrorLocation.errors.txt
-25Lines changed: 0 additions & 25 deletions
This file was deleted.
Collapse file

‎tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt
-36Lines changed: 0 additions & 36 deletions
This file was deleted.
Collapse file

‎tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ class a {
77

88
class b extends a {
99
get x() {
10-
return "20";
10+
return () => "20";
1111
}
12-
set x(aValue: string) {
13-
12+
set x(aValue) {
13+
1414
}
1515
}
1616

@@ -40,7 +40,7 @@ var b = /** @class */ (function (_super) {
4040
}
4141
Object.defineProperty(b.prototype, "x", {
4242
get: function () {
43-
return "20";
43+
return function () { return "20"; };
4444
},
4545
set: function (aValue) {
4646
},
Collapse file

‎tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.symbols‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.symbols
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ class b extends a {
1616
get x() {
1717
>x : Symbol(b.x, Decl(inheritanceMemberAccessorOverridingMethod.ts, 6, 19), Decl(inheritanceMemberAccessorOverridingMethod.ts, 9, 5))
1818

19-
return "20";
19+
return () => "20";
2020
}
21-
set x(aValue: string) {
21+
set x(aValue) {
2222
>x : Symbol(b.x, Decl(inheritanceMemberAccessorOverridingMethod.ts, 6, 19), Decl(inheritanceMemberAccessorOverridingMethod.ts, 9, 5))
2323
>aValue : Symbol(aValue, Decl(inheritanceMemberAccessorOverridingMethod.ts, 10, 10))
24-
24+
2525
}
2626
}
Collapse file

‎tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.types‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.types
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ class b extends a {
1515
>a : a
1616

1717
get x() {
18-
>x : string
18+
>x : () => string
1919

20-
return "20";
20+
return () => "20";
21+
>() => "20" : () => string
2122
>"20" : "20"
2223
}
23-
set x(aValue: string) {
24-
>x : string
25-
>aValue : string
26-
24+
set x(aValue) {
25+
>x : () => string
26+
>aValue : () => string
27+
2728
}
2829
}
Collapse file

‎tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.errors.txt‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.errors.txt
-15Lines changed: 0 additions & 15 deletions
This file was deleted.
Collapse file
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// [propertyOverridingPrototype.ts]
2+
class Base {
3+
foo() {
4+
}
5+
}
6+
7+
class Derived extends Base {
8+
foo: () => { };
9+
}
10+
11+
12+
13+
//// [propertyOverridingPrototype.js]
14+
var __extends = (this && this.__extends) || (function () {
15+
var extendStatics = Object.setPrototypeOf ||
16+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18+
return function (d, b) {
19+
extendStatics(d, b);
20+
function __() { this.constructor = d; }
21+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22+
};
23+
})();
24+
var Base = /** @class */ (function () {
25+
function Base() {
26+
}
27+
Base.prototype.foo = function () {
28+
};
29+
return Base;
30+
}());
31+
var Derived = /** @class */ (function (_super) {
32+
__extends(Derived, _super);
33+
function Derived() {
34+
return _super !== null && _super.apply(this, arguments) || this;
35+
}
36+
return Derived;
37+
}(Base));
Collapse file
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== tests/cases/compiler/propertyOverridingPrototype.ts ===
2+
class Base {
3+
>Base : Symbol(Base, Decl(propertyOverridingPrototype.ts, 0, 0))
4+
5+
foo() {
6+
>foo : Symbol(Base.foo, Decl(propertyOverridingPrototype.ts, 0, 12))
7+
}
8+
}
9+
10+
class Derived extends Base {
11+
>Derived : Symbol(Derived, Decl(propertyOverridingPrototype.ts, 3, 1))
12+
>Base : Symbol(Base, Decl(propertyOverridingPrototype.ts, 0, 0))
13+
14+
foo: () => { };
15+
>foo : Symbol(Derived.foo, Decl(propertyOverridingPrototype.ts, 5, 28))
16+
}
17+
18+
Collapse file
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== tests/cases/compiler/propertyOverridingPrototype.ts ===
2+
class Base {
3+
>Base : Base
4+
5+
foo() {
6+
>foo : () => void
7+
}
8+
}
9+
10+
class Derived extends Base {
11+
>Derived : Derived
12+
>Base : Base
13+
14+
foo: () => { };
15+
>foo : () => {}
16+
}
17+
18+

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.