mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Handle module specifiers
This commit is contained in:
@@ -51,16 +51,6 @@ namespace ts.FindAllReferences {
|
||||
if (!node.parent) return undefined;
|
||||
|
||||
if (!isDeclaration(node.parent) && !isExportAssignment(node.parent)) {
|
||||
// Jsx Tags
|
||||
if (isJsxOpeningElement(node.parent) || isJsxClosingElement(node.parent)) {
|
||||
return node.parent.parent;
|
||||
}
|
||||
else if (isJsxSelfClosingElement(node.parent) ||
|
||||
isLabeledStatement(node.parent) ||
|
||||
isBreakOrContinueStatement(node.parent)) {
|
||||
return node.parent;
|
||||
}
|
||||
|
||||
// Special property assignment in javascript
|
||||
if (isInJSFile(node)) {
|
||||
const binaryExpression = isBinaryExpression(node.parent) ?
|
||||
@@ -75,6 +65,29 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
}
|
||||
|
||||
// Jsx Tags
|
||||
if (isJsxOpeningElement(node.parent) || isJsxClosingElement(node.parent)) {
|
||||
return node.parent.parent;
|
||||
}
|
||||
else if (isJsxSelfClosingElement(node.parent) ||
|
||||
isLabeledStatement(node.parent) ||
|
||||
isBreakOrContinueStatement(node.parent)) {
|
||||
return node.parent;
|
||||
}
|
||||
else if (isStringLiteralLike(node)) {
|
||||
const validImport = tryGetImportFromModuleSpecifier(node);
|
||||
if (validImport) {
|
||||
const declOrStatement = findAncestor(validImport, node =>
|
||||
isDeclaration(node) ||
|
||||
isStatement(node) ||
|
||||
isJSDocTag(node)
|
||||
)! as NamedDeclaration | Statement | JSDocTag;
|
||||
return isDeclaration(declOrStatement) ?
|
||||
getDeclarationForDeclarationSpan(declOrStatement) :
|
||||
declOrStatement;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle computed property name
|
||||
const propertyName = findAncestor(node, isComputedPropertyName);
|
||||
return propertyName ?
|
||||
|
||||
Reference in New Issue
Block a user