Skip to content

fix(47134): Inconsistent QuickInfo on type-only imported symbols #47138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 0 additions & 7 deletions src/services/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ namespace ts {
|| isImportSpecifier(parent)
|| isImportClause(parent)
|| isImportEqualsDeclaration(parent) && node === parent.name) {
let decl: Node = parent;
while (decl) {
if (isImportEqualsDeclaration(decl) || isImportClause(decl) || isExportDeclaration(decl)) {
return decl.isTypeOnly ? SemanticMeaning.Type : SemanticMeaning.All;
}
decl = decl.parent;
}
return SemanticMeaning.All;
}
else if (isInRightSideOfInternalImportEqualsDeclaration(node)) {
Expand Down
6 changes: 3 additions & 3 deletions tests/cases/fourslash/documentHighlightInTypeExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
//// let [|A|]: [|A|] = 1;
//// export type { [|A|] as [|B|] };

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

Expand Down
71 changes: 71 additions & 0 deletions tests/cases/fourslash/quickInfoTypeOnlyImportExport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/// <reference path="fourslash.ts" />

// @Filename: /a.ts
////export type A = number;
////export const A = 42;
////export type B = number;
////export const B = 42;
////
////type C = number;
////const C = 42;
////export type { C };
////type D = number;
////const D = 42;
////export { type D ];

// @Filename: /b.ts
////import type { A/*1*/ } from './a';
////import { type B/*2*/ } from './a';
////import { C/*3*/, D/*4*/ } from './a';
////export type { A/*5*/ } from './a';
////export { type B/*6*/ } from './a';
////export { C/*7*/, D/*8*/ } from './a';

verify.quickInfoAt("1", [
"(alias) type A = number",
"(alias) const A: 42",
"import A",
].join("\n"));

verify.quickInfoAt("2", [
"(alias) type B = number",
"(alias) const B: 42",
"import B",
].join("\n"));

verify.quickInfoAt("3", [
"(alias) type C = number",
"(alias) const C: 42",
"import C",
].join("\n"));

verify.quickInfoAt("4", [
"(alias) type D = number",
"(alias) const D: 42",
"import D",
].join("\n"));

verify.quickInfoAt("5", [
"(alias) type A = number",
"(alias) const A: 42",
"export A",
].join("\n"));

verify.quickInfoAt("6", [
"(alias) type B = number",
"(alias) const B: 42",
"export B",
].join("\n"));

verify.quickInfoAt("7", [
"(alias) type C = number",
"(alias) const C: 42",
"export C",
].join("\n"));

verify.quickInfoAt("8", [
"(alias) type D = number",
"(alias) const D: 42",
"export D",
].join("\n"));