diff --git a/src/services/services.ts b/src/services/services.ts
index e10f639920b..058d4ffdd5e 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -3492,7 +3492,6 @@ module ts {
}
}
- let result: DefinitionInfo[] = [];
// Because name in short-hand property assignment has two different meanings: property name and property value,
// using go-to-definition at such position should go to the variable declaration of the property value rather than
@@ -3501,16 +3500,19 @@ module ts {
// assignment. This case and others are handled by the following code.
if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) {
let shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
+ if (!shorthandSymbol) {
+ return [];
+ }
+
let shorthandDeclarations = shorthandSymbol.getDeclarations();
let shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver, node);
let shorthandSymbolName = typeInfoResolver.symbolToString(shorthandSymbol);
let shorthandContainerName = typeInfoResolver.symbolToString(symbol.parent, node);
- forEach(shorthandDeclarations, declaration => {
- result.push(getDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName));
- });
- return result
+ return map(shorthandDeclarations,
+ declaration => getDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName));
}
+ let result: DefinitionInfo[] = [];
let declarations = symbol.getDeclarations();
let symbolName = typeInfoResolver.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
let symbolKind = getSymbolKind(symbol, typeInfoResolver, node);
diff --git a/tests/cases/fourslash/goToDefinitionShorthandProperty.ts b/tests/cases/fourslash/goToDefinitionShorthandProperty01.ts
similarity index 100%
rename from tests/cases/fourslash/goToDefinitionShorthandProperty.ts
rename to tests/cases/fourslash/goToDefinitionShorthandProperty01.ts
diff --git a/tests/cases/fourslash/goToDefinitionShorthandProperty02.ts b/tests/cases/fourslash/goToDefinitionShorthandProperty02.ts
new file mode 100644
index 00000000000..1f8fe466277
--- /dev/null
+++ b/tests/cases/fourslash/goToDefinitionShorthandProperty02.ts
@@ -0,0 +1,8 @@
+///
+
+////let x = {
+//// f/*1*/oo
+////}
+
+goTo.marker("1");
+verify.not.definitionLocationExists();
\ No newline at end of file
diff --git a/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts b/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts
new file mode 100644
index 00000000000..eb21b159f5a
--- /dev/null
+++ b/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts
@@ -0,0 +1,16 @@
+///
+
+////var /*varDef*/x = {
+//// /*varProp*/x
+////}
+////let /*letDef*/y = {
+//// /*letProp*/y
+////}
+
+goTo.marker("varProp");
+goTo.definition();
+verify.caretAtMarker("varDef");
+
+goTo.marker("letProp");
+goTo.definition();
+verify.caretAtMarker("letDef");
\ No newline at end of file