Skip to content

Commit 7e0e867

Browse files
authored
fix(47134): show all meanings for type-only imports and exports (#47138)
1 parent 8974fea commit 7e0e867

File tree

3 files changed

+74
-10
lines changed

3 files changed

+74
-10
lines changed

src/services/utilities.ts

-7
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,6 @@ namespace ts {
9999
|| isImportSpecifier(parent)
100100
|| isImportClause(parent)
101101
|| isImportEqualsDeclaration(parent) && node === parent.name) {
102-
let decl: Node = parent;
103-
while (decl) {
104-
if (isImportEqualsDeclaration(decl) || isImportClause(decl) || isExportDeclaration(decl)) {
105-
return decl.isTypeOnly ? SemanticMeaning.Type : SemanticMeaning.All;
106-
}
107-
decl = decl.parent;
108-
}
109102
return SemanticMeaning.All;
110103
}
111104
else if (isInRightSideOfInternalImportEqualsDeclaration(node)) {

tests/cases/fourslash/documentHighlightInTypeExport.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
//// let [|A|]: [|A|] = 1;
3131
//// export type { [|A|] as [|B|] };
3232

33-
{ // properly handle type only
33+
{ // type-only exports may still export values to be imported and used in type contexts
3434
const [AType, ALet, ADecl, AExport, asB] = test.rangesInFile("/3.ts");
3535
verify.documentHighlightsOf(AType, [AType, ADecl, AExport, asB]);
3636
verify.documentHighlightsOf(ADecl, [AType, ADecl, AExport, asB]);
37-
verify.documentHighlightsOf(AExport, [AType, ADecl, AExport, asB]);
38-
verify.documentHighlightsOf(ALet, [ALet]);
37+
verify.documentHighlightsOf(AExport, [AType, ALet, ADecl, AExport, asB]);
38+
verify.documentHighlightsOf(ALet, [ALet, AExport, asB]);
3939
verify.documentHighlightsOf(asB, [asB]);
4040
}
4141

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @Filename: /a.ts
4+
////export type A = number;
5+
////export const A = 42;
6+
////export type B = number;
7+
////export const B = 42;
8+
////
9+
////type C = number;
10+
////const C = 42;
11+
////export type { C };
12+
////type D = number;
13+
////const D = 42;
14+
////export { type D ];
15+
16+
// @Filename: /b.ts
17+
////import type { A/*1*/ } from './a';
18+
////import { type B/*2*/ } from './a';
19+
////import { C/*3*/, D/*4*/ } from './a';
20+
////export type { A/*5*/ } from './a';
21+
////export { type B/*6*/ } from './a';
22+
////export { C/*7*/, D/*8*/ } from './a';
23+
24+
verify.quickInfoAt("1", [
25+
"(alias) type A = number",
26+
"(alias) const A: 42",
27+
"import A",
28+
].join("\n"));
29+
30+
verify.quickInfoAt("2", [
31+
"(alias) type B = number",
32+
"(alias) const B: 42",
33+
"import B",
34+
].join("\n"));
35+
36+
verify.quickInfoAt("3", [
37+
"(alias) type C = number",
38+
"(alias) const C: 42",
39+
"import C",
40+
].join("\n"));
41+
42+
verify.quickInfoAt("4", [
43+
"(alias) type D = number",
44+
"(alias) const D: 42",
45+
"import D",
46+
].join("\n"));
47+
48+
verify.quickInfoAt("5", [
49+
"(alias) type A = number",
50+
"(alias) const A: 42",
51+
"export A",
52+
].join("\n"));
53+
54+
verify.quickInfoAt("6", [
55+
"(alias) type B = number",
56+
"(alias) const B: 42",
57+
"export B",
58+
].join("\n"));
59+
60+
verify.quickInfoAt("7", [
61+
"(alias) type C = number",
62+
"(alias) const C: 42",
63+
"export C",
64+
].join("\n"));
65+
66+
verify.quickInfoAt("8", [
67+
"(alias) type D = number",
68+
"(alias) const D: 42",
69+
"export D",
70+
].join("\n"));
71+

0 commit comments

Comments
 (0)