Skip to content

Commit b261268

Browse files
committed
fix(47134): support type modifier on import/export names in
`getMeaningFromLocation()`
1 parent d417058 commit b261268

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/services/utilities.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ namespace ts {
101101
|| isImportEqualsDeclaration(parent) && node === parent.name) {
102102
let decl: Node = parent;
103103
while (decl) {
104+
if (isImportOrExportSpecifier(decl)) {
105+
// Don't return `SemanticMeaning.All` when `!decl.isTypeOnly`, as the node's ancestor may contain `type` modifier.
106+
if (decl.isTypeOnly) {
107+
return SemanticMeaning.Type;
108+
}
109+
}
104110
if (isImportEqualsDeclaration(decl) || isImportClause(decl) || isExportDeclaration(decl)) {
105111
return decl.isTypeOnly ? SemanticMeaning.Type : SemanticMeaning.All;
106112
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
// @Filename: /b.ts
10+
////import type { A/*1*/ } from './a';
11+
////import { type B/*2*/ } from './a';
12+
////export type { A/*3*/ } from './a';
13+
////export { type B/*4*/ } from './a';
14+
15+
verify.quickInfoAt("1", [
16+
"(alias) type A = number",
17+
"import A",
18+
].join("\n"));
19+
20+
verify.quickInfoAt("2", [
21+
"(alias) type B = number",
22+
"import B",
23+
].join("\n"));
24+
25+
verify.quickInfoAt("3", [
26+
"(alias) type A = number",
27+
"export A",
28+
].join("\n"));
29+
30+
verify.quickInfoAt("4", [
31+
"(alias) type B = number",
32+
"export B",
33+
].join("\n"));

0 commit comments

Comments
 (0)