Skip to content

Commit a0c8911

Browse files
committed
fix the other thing
1 parent 31b5724 commit a0c8911

19 files changed

+1581
-13
lines changed

src/services/importTracker.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
getNameOfAccessExpression,
2222
getSourceFileOfNode,
2323
getSymbolId,
24+
getSymbolTarget,
2425
hasSyntacticModifier,
2526
Identifier,
2627
ImportCall,
@@ -637,9 +638,12 @@ export function getImportOrExportSymbol(node: Node, symbol: Symbol, checker: Typ
637638
}
638639
else {
639640
const sourceFile = getSourceFileOfNode(node);
640-
if (sourceFile.symbol.exports?.has(InternalSymbolName.ExportEquals) && checker.resolveExternalModuleSymbol(sourceFile.symbol) === symbol.parent) {
641-
const exportInfo = { exportingModuleSymbol: sourceFile.symbol, exportKind: ExportKind.Named };
642-
return { kind: ImportExport.Export, symbol, exportInfo };
641+
if (sourceFile.symbol?.exports?.has(InternalSymbolName.ExportEquals)) {
642+
const moduleSymbol = checker.resolveExternalModuleSymbol(sourceFile.symbol);
643+
if (moduleSymbol && (moduleSymbol === symbol.parent || some(checker.getPropertiesOfType(checker.getTypeOfSymbol(moduleSymbol)), s => getSymbolTarget(s, checker) === symbol))) {
644+
const exportInfo = { exportingModuleSymbol: sourceFile.symbol, exportKind: ExportKind.Named };
645+
return { kind: ImportExport.Export, symbol, exportInfo };
646+
}
643647
}
644648
}
645649
}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
// === findAllReferences ===
2+
// === /mod.ts ===
3+
// class Cls {
4+
// /*FIND ALL REFS*/<|[|{| isWriteAccess: true, isDefinition: true |}foo|]() {}|>
5+
// };
6+
//
7+
// export default new Cls();
8+
9+
// === /index.ts ===
10+
// import def from "./mod"
11+
// def.[|foo|]();
12+
13+
// === Definitions ===
14+
// === /mod.ts ===
15+
// class Cls {
16+
// /*FIND ALL REFS*/<|[|foo|]() {}|>
17+
// };
18+
//
19+
// export default new Cls();
20+
21+
// === Details ===
22+
[
23+
{
24+
"containerKind": "",
25+
"containerName": "",
26+
"kind": "method",
27+
"name": "(method) Cls.foo(): void",
28+
"displayParts": [
29+
{
30+
"text": "(",
31+
"kind": "punctuation"
32+
},
33+
{
34+
"text": "method",
35+
"kind": "text"
36+
},
37+
{
38+
"text": ")",
39+
"kind": "punctuation"
40+
},
41+
{
42+
"text": " ",
43+
"kind": "space"
44+
},
45+
{
46+
"text": "Cls",
47+
"kind": "className"
48+
},
49+
{
50+
"text": ".",
51+
"kind": "punctuation"
52+
},
53+
{
54+
"text": "foo",
55+
"kind": "methodName"
56+
},
57+
{
58+
"text": "(",
59+
"kind": "punctuation"
60+
},
61+
{
62+
"text": ")",
63+
"kind": "punctuation"
64+
},
65+
{
66+
"text": ":",
67+
"kind": "punctuation"
68+
},
69+
{
70+
"text": " ",
71+
"kind": "space"
72+
},
73+
{
74+
"text": "void",
75+
"kind": "keyword"
76+
}
77+
]
78+
}
79+
]
80+
81+
82+
83+
// === findAllReferences ===
84+
// === /mod.ts ===
85+
// class Cls {
86+
// <|[|{| isWriteAccess: true |}foo|]() {}|>
87+
// };
88+
//
89+
// export default new Cls();
90+
91+
// === /index.ts ===
92+
// import def from "./mod"
93+
// def.[|foo|]/*FIND ALL REFS*/();
94+
95+
// === Definitions ===
96+
// === /mod.ts ===
97+
// class Cls {
98+
// <|[|foo|]() {}|>
99+
// };
100+
//
101+
// export default new Cls();
102+
103+
// === Details ===
104+
[
105+
{
106+
"containerKind": "",
107+
"containerName": "",
108+
"kind": "method",
109+
"name": "(method) Cls.foo(): void",
110+
"displayParts": [
111+
{
112+
"text": "(",
113+
"kind": "punctuation"
114+
},
115+
{
116+
"text": "method",
117+
"kind": "text"
118+
},
119+
{
120+
"text": ")",
121+
"kind": "punctuation"
122+
},
123+
{
124+
"text": " ",
125+
"kind": "space"
126+
},
127+
{
128+
"text": "Cls",
129+
"kind": "className"
130+
},
131+
{
132+
"text": ".",
133+
"kind": "punctuation"
134+
},
135+
{
136+
"text": "foo",
137+
"kind": "methodName"
138+
},
139+
{
140+
"text": "(",
141+
"kind": "punctuation"
142+
},
143+
{
144+
"text": ")",
145+
"kind": "punctuation"
146+
},
147+
{
148+
"text": ":",
149+
"kind": "punctuation"
150+
},
151+
{
152+
"text": " ",
153+
"kind": "space"
154+
},
155+
{
156+
"text": "void",
157+
"kind": "keyword"
158+
}
159+
]
160+
}
161+
]
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// === findAllReferences ===
2+
// === /mod.d.ts ===
3+
// export default React;
4+
//
5+
// declare namespace React {
6+
// <|function /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}lazy|](): void;|>
7+
// }
8+
9+
// === /index.ts ===
10+
// import def from "./mod"
11+
// def.[|lazy|]();
12+
13+
// === Definitions ===
14+
// === /mod.d.ts ===
15+
// export default React;
16+
//
17+
// declare namespace React {
18+
// <|function /*FIND ALL REFS*/[|lazy|](): void;|>
19+
// }
20+
21+
// === Details ===
22+
[
23+
{
24+
"containerKind": "",
25+
"containerName": "",
26+
"kind": "function",
27+
"name": "function React.lazy(): void",
28+
"displayParts": [
29+
{
30+
"text": "function",
31+
"kind": "keyword"
32+
},
33+
{
34+
"text": " ",
35+
"kind": "space"
36+
},
37+
{
38+
"text": "React",
39+
"kind": "moduleName"
40+
},
41+
{
42+
"text": ".",
43+
"kind": "punctuation"
44+
},
45+
{
46+
"text": "lazy",
47+
"kind": "functionName"
48+
},
49+
{
50+
"text": "(",
51+
"kind": "punctuation"
52+
},
53+
{
54+
"text": ")",
55+
"kind": "punctuation"
56+
},
57+
{
58+
"text": ":",
59+
"kind": "punctuation"
60+
},
61+
{
62+
"text": " ",
63+
"kind": "space"
64+
},
65+
{
66+
"text": "void",
67+
"kind": "keyword"
68+
}
69+
]
70+
}
71+
]
72+
73+
74+
75+
// === findAllReferences ===
76+
// === /mod.d.ts ===
77+
// export default React;
78+
//
79+
// declare namespace React {
80+
// <|function [|{| isWriteAccess: true |}lazy|](): void;|>
81+
// }
82+
83+
// === /index.ts ===
84+
// import def from "./mod"
85+
// def.[|lazy|]/*FIND ALL REFS*/();
86+
87+
// === Definitions ===
88+
// === /mod.d.ts ===
89+
// export default React;
90+
//
91+
// declare namespace React {
92+
// <|function [|lazy|](): void;|>
93+
// }
94+
95+
// === Details ===
96+
[
97+
{
98+
"containerKind": "",
99+
"containerName": "",
100+
"kind": "function",
101+
"name": "function React.lazy(): void",
102+
"displayParts": [
103+
{
104+
"text": "function",
105+
"kind": "keyword"
106+
},
107+
{
108+
"text": " ",
109+
"kind": "space"
110+
},
111+
{
112+
"text": "React",
113+
"kind": "moduleName"
114+
},
115+
{
116+
"text": ".",
117+
"kind": "punctuation"
118+
},
119+
{
120+
"text": "lazy",
121+
"kind": "functionName"
122+
},
123+
{
124+
"text": "(",
125+
"kind": "punctuation"
126+
},
127+
{
128+
"text": ")",
129+
"kind": "punctuation"
130+
},
131+
{
132+
"text": ":",
133+
"kind": "punctuation"
134+
},
135+
{
136+
"text": " ",
137+
"kind": "space"
138+
},
139+
{
140+
"text": "void",
141+
"kind": "keyword"
142+
}
143+
]
144+
}
145+
]

0 commit comments

Comments
 (0)