Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/services/importTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
getNameOfAccessExpression,
getSourceFileOfNode,
getSymbolId,
getSymbolTarget,
hasSyntacticModifier,
Identifier,
ImportCall,
Expand Down Expand Up @@ -635,6 +636,16 @@ export function getImportOrExportSymbol(node: Node, symbol: Symbol, checker: Typ
else if (isJSDocTypedefTag(parent) || isJSDocCallbackTag(parent)) {
return exportInfo(symbol, ExportKind.Named);
}
else {
const sourceFile = getSourceFileOfNode(node);
if (sourceFile.symbol?.exports?.has(InternalSymbolName.ExportEquals)) {
const moduleSymbol = checker.resolveExternalModuleSymbol(sourceFile.symbol);
if (moduleSymbol && (moduleSymbol === symbol.parent || some(checker.getPropertiesOfType(checker.getTypeOfSymbol(moduleSymbol)), s => getSymbolTarget(s, checker) === symbol))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to suggestions how to improve some(getPropertiesOfType(getTypeOfSymbol(...)), ...) bit. I couldn't find an easier way to do this for the presented object literal (and class instance!) cases.

This comment was marked as spam.

const exportInfo = { exportingModuleSymbol: sourceFile.symbol, exportKind: ExportKind.Named };
return { kind: ImportExport.Export, symbol, exportInfo };
}
}
}
}

function getExportAssignmentExport(ex: ExportAssignment): ExportedSymbol | undefined {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
// === findAllReferences ===
// === /mod.ts ===
// class Cls {
// /*FIND ALL REFS*/<|[|{| isWriteAccess: true, isDefinition: true |}foo|]() {}|>
// };
//
// export default new Cls();

// === /index.ts ===
// import def from "./mod"
// def.[|foo|]();

// === Definitions ===
// === /mod.ts ===
// class Cls {
// /*FIND ALL REFS*/<|[|foo|]() {}|>
// };
//
// export default new Cls();

// === Details ===
[
{
"containerKind": "",
"containerName": "",
"kind": "method",
"name": "(method) Cls.foo(): void",
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Cls",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
]
}
]



// === findAllReferences ===
// === /mod.ts ===
// class Cls {
// <|[|{| isWriteAccess: true |}foo|]() {}|>
// };
//
// export default new Cls();

// === /index.ts ===
// import def from "./mod"
// def.[|foo|]/*FIND ALL REFS*/();

// === Definitions ===
// === /mod.ts ===
// class Cls {
// <|[|foo|]() {}|>
// };
//
// export default new Cls();

// === Details ===
[
{
"containerKind": "",
"containerName": "",
"kind": "method",
"name": "(method) Cls.foo(): void",
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Cls",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// === findAllReferences ===
// === /mod.d.ts ===
// export default React;
//
// declare namespace React {
// <|function /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}lazy|](): void;|>
// }

// === /index.ts ===
// import def from "./mod"
// def.[|lazy|]();

// === Definitions ===
// === /mod.d.ts ===
// export default React;
//
// declare namespace React {
// <|function /*FIND ALL REFS*/[|lazy|](): void;|>
// }

// === Details ===
[
{
"containerKind": "",
"containerName": "",
"kind": "function",
"name": "function React.lazy(): void",
"displayParts": [
{
"text": "function",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "React",
"kind": "moduleName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "lazy",
"kind": "functionName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
]
}
]



// === findAllReferences ===
// === /mod.d.ts ===
// export default React;
//
// declare namespace React {
// <|function [|{| isWriteAccess: true |}lazy|](): void;|>
// }

// === /index.ts ===
// import def from "./mod"
// def.[|lazy|]/*FIND ALL REFS*/();

// === Definitions ===
// === /mod.d.ts ===
// export default React;
//
// declare namespace React {
// <|function [|lazy|](): void;|>
// }

// === Details ===
[
{
"containerKind": "",
"containerName": "",
"kind": "function",
"name": "function React.lazy(): void",
"displayParts": [
{
"text": "function",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "React",
"kind": "moduleName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "lazy",
"kind": "functionName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
]
}
]
Loading
Loading