Skip to content

Commit 95f6a07

Browse files
committed
fix(42923): add go-to-definition on unresolved shorthand properties
1 parent b0474dd commit 95f6a07

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

src/services/goToDefinition.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ namespace ts.GoToDefinition {
5151
// assignment. This case and others are handled by the following code.
5252
if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) {
5353
const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
54-
return shorthandSymbol ? shorthandSymbol.declarations.map(decl => createDefinitionInfo(decl, typeChecker, shorthandSymbol, node)) : [];
54+
if (shorthandSymbol) {
55+
return shorthandSymbol.declarations.map(decl => createDefinitionInfo(decl, typeChecker, shorthandSymbol, node));
56+
}
5557
}
5658

5759
// If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
@@ -91,6 +93,7 @@ namespace ts.GoToDefinition {
9193
return flatMap(getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), propertySymbol =>
9294
getDefinitionFromSymbol(typeChecker, propertySymbol, node));
9395
}
96+
return [];
9497
}
9598

9699
return getDefinitionFromSymbol(typeChecker, symbol, node);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="./fourslash.ts"/>
2+
3+
////interface Foo {
4+
//// /*2*/foo(): void
5+
////}
6+
////
7+
////let x: Foo = {
8+
//// [|f/*1*/oo|]
9+
////}
10+
11+
verify.goToDefinition("1", "2");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="./fourslash.ts"/>
2+
3+
////interface Foo {
4+
//// foo(): void
5+
////}
6+
////const /*2*/foo = 1;
7+
////let x: Foo = {
8+
//// [|f/*1*/oo|]
9+
////}
10+
11+
verify.goToDefinition("1", "2");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="./fourslash.ts"/>
2+
3+
////interface Foo {
4+
//// /*2*/foo(): void
5+
////}
6+
////const foo = 1;
7+
////let x: Foo = {
8+
//// [|f/*1*/oo|]()
9+
////}
10+
11+
verify.goToDefinition("1", "2");

0 commit comments

Comments
 (0)