Skip to content

Commit 5773723

Browse files
Cherry-pick #50724 to release-4.8 (#50760)
Co-authored-by: Oleksandr T <[email protected]>
1 parent a3b3555 commit 5773723

File tree

7 files changed

+94
-2
lines changed

7 files changed

+94
-2
lines changed

src/compiler/parser.ts

+1
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ namespace ts {
662662
case SyntaxKind.JSDocProtectedTag:
663663
case SyntaxKind.JSDocReadonlyTag:
664664
case SyntaxKind.JSDocDeprecatedTag:
665+
case SyntaxKind.JSDocOverrideTag:
665666
return visitNode(cbNode, (node as JSDocTag).tagName)
666667
|| (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined));
667668
case SyntaxKind.PartiallyEmittedExpression:

src/services/goToDefinition.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace ts.GoToDefinition {
1616
const { parent } = node;
1717
const typeChecker = program.getTypeChecker();
1818

19-
if (node.kind === SyntaxKind.OverrideKeyword || (isJSDocOverrideTag(node) && rangeContainsPosition(node.tagName, position))) {
19+
if (node.kind === SyntaxKind.OverrideKeyword || (isIdentifier(node) && isJSDocOverrideTag(parent) && parent.tagName === node)) {
2020
return getDefinitionFromOverriddenMember(typeChecker, node) || emptyArray;
2121
}
2222

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//// [a.ts]
2+
class A {
3+
foo() {}
4+
}
5+
class B extends A {
6+
/**
7+
* @override {@link A.foo}
8+
*/
9+
foo() {}
10+
}
11+
12+
13+
//// [a.js]
14+
var __extends = (this && this.__extends) || (function () {
15+
var extendStatics = function (d, b) {
16+
extendStatics = Object.setPrototypeOf ||
17+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
19+
return extendStatics(d, b);
20+
};
21+
return function (d, b) {
22+
if (typeof b !== "function" && b !== null)
23+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
24+
extendStatics(d, b);
25+
function __() { this.constructor = d; }
26+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27+
};
28+
})();
29+
var A = /** @class */ (function () {
30+
function A() {
31+
}
32+
A.prototype.foo = function () { };
33+
return A;
34+
}());
35+
var B = /** @class */ (function (_super) {
36+
__extends(B, _super);
37+
function B() {
38+
return _super !== null && _super.apply(this, arguments) || this;
39+
}
40+
/**
41+
* @override {@link A.foo}
42+
*/
43+
B.prototype.foo = function () { };
44+
return B;
45+
}(A));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== /a.ts ===
2+
class A {
3+
>A : Symbol(A, Decl(a.ts, 0, 0))
4+
5+
foo() {}
6+
>foo : Symbol(A.foo, Decl(a.ts, 0, 9))
7+
}
8+
class B extends A {
9+
>B : Symbol(B, Decl(a.ts, 2, 1))
10+
>A : Symbol(A, Decl(a.ts, 0, 0))
11+
12+
/**
13+
* @override {@link A.foo}
14+
*/
15+
foo() {}
16+
>foo : Symbol(B.foo, Decl(a.ts, 3, 19))
17+
}
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== /a.ts ===
2+
class A {
3+
>A : A
4+
5+
foo() {}
6+
>foo : () => void
7+
}
8+
class B extends A {
9+
>B : B
10+
>A : A
11+
12+
/**
13+
* @override {@link A.foo}
14+
*/
15+
foo() {}
16+
>foo : () => void
17+
}
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @filename: /a.ts
2+
class A {
3+
foo() {}
4+
}
5+
class B extends A {
6+
/**
7+
* @override {@link A.foo}
8+
*/
9+
foo() {}
10+
}

tests/cases/fourslash/goToDefinitionOverriddenMember11.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//// /*Foo_m*/m() {}
1111
////}
1212
////class Bar extends Foo {
13-
//// /** [|@over{|"name": "1"|}ride[| se{|"name": "2"|}e {@li{|"name": "3"|}nk https://test.c{|"name": "4"|}om} {|"name": "5"|}description |]|]*/
13+
//// /** @[|over{|"name": "1"|}ride|][| se{|"name": "2"|}e {@li{|"name": "3"|}nk https://test.c{|"name": "4"|}om} {|"name": "5"|}description |]*/
1414
//// m() {}
1515
////}
1616

0 commit comments

Comments
 (0)