diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 89979d4cef46a..593cbc73913f7 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -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)) { diff --git a/tests/cases/fourslash/documentHighlightInTypeExport.ts b/tests/cases/fourslash/documentHighlightInTypeExport.ts index 5a16a9bbc90e9..d4ea0404a6d15 100644 --- a/tests/cases/fourslash/documentHighlightInTypeExport.ts +++ b/tests/cases/fourslash/documentHighlightInTypeExport.ts @@ -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]); } diff --git a/tests/cases/fourslash/quickInfoTypeOnlyImportExport.ts b/tests/cases/fourslash/quickInfoTypeOnlyImportExport.ts new file mode 100644 index 0000000000000..1688d0bdee053 --- /dev/null +++ b/tests/cases/fourslash/quickInfoTypeOnlyImportExport.ts @@ -0,0 +1,71 @@ +/// + +// @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")); +