mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #2415 from Microsoft/shorthandsOnNonExistentProperty
Fixed crash on goToDef when a shorthand property refers to an undefined entity
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////let x = {
|
||||
//// f/*1*/oo
|
||||
////}
|
||||
|
||||
goTo.marker("1");
|
||||
verify.not.definitionLocationExists();
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////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");
|
||||
Reference in New Issue
Block a user