From 31b57248a4bba3129349f4dfaeb25be4b26404dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 10 Sep 2025 11:18:24 +0200 Subject: [PATCH 1/4] Find references in importing modules for members of `export =`ed symbols --- src/services/importTracker.ts | 7 + ...ualExportedNamespaceMember1.baseline.jsonc | 453 ++++++++++++++++ ...ualExportedNamespaceMember2.baseline.jsonc | 489 ++++++++++++++++++ ...ualExportedNamespaceMember3.baseline.jsonc | 131 +++++ ...sEqualExportedObjectMember1.baseline.jsonc | 295 +++++++++++ ...sEqualExportedObjectMember2.baseline.jsonc | 299 +++++++++++ ...indAllRefsEqualExportedNamespaceMember1.ts | 16 + ...indAllRefsEqualExportedNamespaceMember2.ts | 18 + ...indAllRefsEqualExportedNamespaceMember3.ts | 16 + .../findAllRefsEqualExportedObjectMember1.ts | 16 + .../findAllRefsEqualExportedObjectMember2.ts | 18 + 11 files changed, 1758 insertions(+) create mode 100644 tests/baselines/reference/findAllRefsEqualExportedNamespaceMember1.baseline.jsonc create mode 100644 tests/baselines/reference/findAllRefsEqualExportedNamespaceMember2.baseline.jsonc create mode 100644 tests/baselines/reference/findAllRefsEqualExportedNamespaceMember3.baseline.jsonc create mode 100644 tests/baselines/reference/findAllRefsEqualExportedObjectMember1.baseline.jsonc create mode 100644 tests/baselines/reference/findAllRefsEqualExportedObjectMember2.baseline.jsonc create mode 100644 tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember1.ts create mode 100644 tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember2.ts create mode 100644 tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember3.ts create mode 100644 tests/cases/fourslash/findAllRefsEqualExportedObjectMember1.ts create mode 100644 tests/cases/fourslash/findAllRefsEqualExportedObjectMember2.ts diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 316d3874fb40e..365e59a1d64a3 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -635,6 +635,13 @@ export function getImportOrExportSymbol(node: Node, symbol: Symbol, checker: Typ else if (isJSDocTypedefTag(parent) || isJSDocCallbackTag(parent)) { return exportInfo(symbol, ExportKind.Named); } + else { + const sourceFile = getSourceFileOfNode(node); + if (sourceFile.symbol.exports?.has(InternalSymbolName.ExportEquals) && checker.resolveExternalModuleSymbol(sourceFile.symbol) === symbol.parent) { + const exportInfo = { exportingModuleSymbol: sourceFile.symbol, exportKind: ExportKind.Named }; + return { kind: ImportExport.Export, symbol, exportInfo }; + } + } } function getExportAssignmentExport(ex: ExportAssignment): ExportedSymbol | undefined { diff --git a/tests/baselines/reference/findAllRefsEqualExportedNamespaceMember1.baseline.jsonc b/tests/baselines/reference/findAllRefsEqualExportedNamespaceMember1.baseline.jsonc new file mode 100644 index 0000000000000..297a5e0dff41d --- /dev/null +++ b/tests/baselines/reference/findAllRefsEqualExportedNamespaceMember1.baseline.jsonc @@ -0,0 +1,453 @@ +// === findAllReferences === +// === /mod.d.ts === +// export = React; +// +// declare namespace React { +// <|function /*FIND ALL REFS*/[|{| defId: 0, isWriteAccess: true, isDefinition: true |}lazy|](): void;|> +// } + +// === /index.ts === +// <|import { [|{| defId: 1, isWriteAccess: true |}lazy|] } from "./mod"|> +// [|{| defId: 1 |}lazy|](); + + // === Definitions === + // === /mod.d.ts === + // export = React; + // + // declare namespace React { + // <|function /*FIND ALL REFS*/[|{| defId: 0 |}lazy|](): void;|> + // } + + // === /index.ts === + // <|import { [|{| defId: 1 |}lazy|] } from "./mod"|> + // lazy(); + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function React.lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "React", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) function lazy(): void\nimport lazy", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { /*FIND ALL REFS*/[|{| defId: 0, isWriteAccess: true, isDefinition: true |}lazy|] } from "./mod"|> +// [|{| defId: 0 |}lazy|](); + +// === /mod.d.ts === +// export = React; +// +// declare namespace React { +// <|function [|{| defId: 1, isWriteAccess: true |}lazy|](): void;|> +// } + + // === Definitions === + // === /index.ts === + // <|import { /*FIND ALL REFS*/[|{| defId: 0 |}lazy|] } from "./mod"|> + // lazy(); + + // === /mod.d.ts === + // export = React; + // + // declare namespace React { + // <|function [|{| defId: 1 |}lazy|](): void;|> + // } + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) function lazy(): void\nimport lazy", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function React.lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "React", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { [|{| defId: 0, isWriteAccess: true |}lazy|] } from "./mod"|> +// /*FIND ALL REFS*/[|{| defId: 0 |}lazy|](); + +// === /mod.d.ts === +// export = React; +// +// declare namespace React { +// <|function [|{| defId: 1, isWriteAccess: true |}lazy|](): void;|> +// } + + // === Definitions === + // === /index.ts === + // <|import { [|{| defId: 0 |}lazy|] } from "./mod"|> + // /*FIND ALL REFS*/lazy(); + + // === /mod.d.ts === + // export = React; + // + // declare namespace React { + // <|function [|{| defId: 1 |}lazy|](): void;|> + // } + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) function lazy(): void\nimport lazy", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function React.lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "React", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsEqualExportedNamespaceMember2.baseline.jsonc b/tests/baselines/reference/findAllRefsEqualExportedNamespaceMember2.baseline.jsonc new file mode 100644 index 0000000000000..43a208052696c --- /dev/null +++ b/tests/baselines/reference/findAllRefsEqualExportedNamespaceMember2.baseline.jsonc @@ -0,0 +1,489 @@ +// === findAllReferences === +// === /mod.d.ts === +// export = Outer.Inner; +// +// declare namespace Outer { +// namespace Inner { +// <|function /*FIND ALL REFS*/[|{| defId: 0, isWriteAccess: true, isDefinition: true |}lazy|](): void;|> +// } +// } + +// === /index.ts === +// <|import { [|{| defId: 1, isWriteAccess: true |}lazy|] } from "./mod"|> +// [|{| defId: 1 |}lazy|](); + + // === Definitions === + // === /mod.d.ts === + // export = Outer.Inner; + // + // declare namespace Outer { + // namespace Inner { + // <|function /*FIND ALL REFS*/[|{| defId: 0 |}lazy|](): void;|> + // } + // } + + // === /index.ts === + // <|import { [|{| defId: 1 |}lazy|] } from "./mod"|> + // lazy(); + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function Outer.Inner.lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Outer", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Inner", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) function lazy(): void\nimport lazy", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { /*FIND ALL REFS*/[|{| defId: 0, isWriteAccess: true, isDefinition: true |}lazy|] } from "./mod"|> +// [|{| defId: 0 |}lazy|](); + +// === /mod.d.ts === +// export = Outer.Inner; +// +// declare namespace Outer { +// namespace Inner { +// <|function [|{| defId: 1, isWriteAccess: true |}lazy|](): void;|> +// } +// } + + // === Definitions === + // === /index.ts === + // <|import { /*FIND ALL REFS*/[|{| defId: 0 |}lazy|] } from "./mod"|> + // lazy(); + + // === /mod.d.ts === + // export = Outer.Inner; + // + // declare namespace Outer { + // namespace Inner { + // <|function [|{| defId: 1 |}lazy|](): void;|> + // } + // } + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) function lazy(): void\nimport lazy", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function Outer.Inner.lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Outer", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Inner", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { [|{| defId: 0, isWriteAccess: true |}lazy|] } from "./mod"|> +// /*FIND ALL REFS*/[|{| defId: 0 |}lazy|](); + +// === /mod.d.ts === +// export = Outer.Inner; +// +// declare namespace Outer { +// namespace Inner { +// <|function [|{| defId: 1, isWriteAccess: true |}lazy|](): void;|> +// } +// } + + // === Definitions === + // === /index.ts === + // <|import { [|{| defId: 0 |}lazy|] } from "./mod"|> + // /*FIND ALL REFS*/lazy(); + + // === /mod.d.ts === + // export = Outer.Inner; + // + // declare namespace Outer { + // namespace Inner { + // <|function [|{| defId: 1 |}lazy|](): void;|> + // } + // } + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) function lazy(): void\nimport lazy", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function Outer.Inner.lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Outer", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Inner", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsEqualExportedNamespaceMember3.baseline.jsonc b/tests/baselines/reference/findAllRefsEqualExportedNamespaceMember3.baseline.jsonc new file mode 100644 index 0000000000000..5d663ab9fa855 --- /dev/null +++ b/tests/baselines/reference/findAllRefsEqualExportedNamespaceMember3.baseline.jsonc @@ -0,0 +1,131 @@ +// === findAllReferences === +// === /mod.ts === +// export = Ns; +// +// namespace Ns { +// <|function /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}lazy|]() {}|> // this *isn't* exported from the namespace +// } + + // === Definitions === + // === /mod.ts === + // export = Ns; + // + // namespace Ns { + // <|function /*FIND ALL REFS*/[|lazy|]() {}|> // this *isn't* exported from the namespace + // } + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}lazy|] } from "./mod"|> +// [|lazy|](); + + // === Definitions === + // === /index.ts === + // <|import { /*FIND ALL REFS*/[|lazy|] } from "./mod"|> + // lazy(); + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "import lazy", + "displayParts": [ + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { [|{| isWriteAccess: true |}lazy|] } from "./mod"|> +// /*FIND ALL REFS*/[|lazy|](); + + // === Definitions === + // === /index.ts === + // <|import { [|lazy|] } from "./mod"|> + // /*FIND ALL REFS*/lazy(); + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "import lazy", + "displayParts": [ + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "aliasName" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsEqualExportedObjectMember1.baseline.jsonc b/tests/baselines/reference/findAllRefsEqualExportedObjectMember1.baseline.jsonc new file mode 100644 index 0000000000000..1ba3f8631b0b9 --- /dev/null +++ b/tests/baselines/reference/findAllRefsEqualExportedObjectMember1.baseline.jsonc @@ -0,0 +1,295 @@ +// === findAllReferences === +// === /mod.d.ts === +// const obj = { +// /*FIND ALL REFS*/<|[|{| isWriteAccess: true, isDefinition: true |}foo|]: () => ""|>, +// }; +// +// export = obj; + + // === Definitions === + // === /mod.d.ts === + // const obj = { + // /*FIND ALL REFS*/<|[|foo|]: () => ""|>, + // }; + // + // export = obj; + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "property", + "name": "(property) foo: () => string", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}foo|] } from "./mod"|> +// [|foo|](); + + // === Definitions === + // === /index.ts === + // <|import { /*FIND ALL REFS*/[|foo|] } from "./mod"|> + // foo(); + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) (property) foo: () => string\nimport foo", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { [|{| isWriteAccess: true |}foo|] } from "./mod"|> +// /*FIND ALL REFS*/[|foo|](); + + // === Definitions === + // === /index.ts === + // <|import { [|foo|] } from "./mod"|> + // /*FIND ALL REFS*/foo(); + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) (property) foo: () => string\nimport foo", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsEqualExportedObjectMember2.baseline.jsonc b/tests/baselines/reference/findAllRefsEqualExportedObjectMember2.baseline.jsonc new file mode 100644 index 0000000000000..6ca2478e8cea2 --- /dev/null +++ b/tests/baselines/reference/findAllRefsEqualExportedObjectMember2.baseline.jsonc @@ -0,0 +1,299 @@ +// === findAllReferences === +// === /mod.d.ts === +// const obj = { +// nested: { +// /*FIND ALL REFS*/<|[|{| isWriteAccess: true, isDefinition: true |}foo|]: () => ""|>, +// }, +// }; +// +// export = obj.nested; + + // === Definitions === + // === /mod.d.ts === + // const obj = { + // nested: { + // /*FIND ALL REFS*/<|[|foo|]: () => ""|>, + // }, + // }; + // + // export = obj.nested; + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "property", + "name": "(property) foo: () => string", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}foo|] } from "./mod"|> +// [|foo|](); + + // === Definitions === + // === /index.ts === + // <|import { /*FIND ALL REFS*/[|foo|] } from "./mod"|> + // foo(); + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) (property) foo: () => string\nimport foo", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { [|{| isWriteAccess: true |}foo|] } from "./mod"|> +// /*FIND ALL REFS*/[|foo|](); + + // === Definitions === + // === /index.ts === + // <|import { [|foo|] } from "./mod"|> + // /*FIND ALL REFS*/foo(); + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) (property) foo: () => string\nimport foo", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + } + ] + } + ] \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember1.ts b/tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember1.ts new file mode 100644 index 0000000000000..ac8a3a047ce96 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember1.ts @@ -0,0 +1,16 @@ +/// + +// @module: commonjs + +// @Filename: /mod.d.ts +//// export = React; +//// +//// declare namespace React { +//// function /*1*/lazy(): void; +//// } + +// @Filename: /index.ts +//// import { /*2*/lazy } from "./mod" +//// /*3*/lazy(); + +verify.baselineFindAllReferences("1", "2", "3"); diff --git a/tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember2.ts b/tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember2.ts new file mode 100644 index 0000000000000..6831720be7b1b --- /dev/null +++ b/tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember2.ts @@ -0,0 +1,18 @@ +/// + +// @module: commonjs + +// @Filename: /mod.d.ts +//// export = Outer.Inner; +//// +//// declare namespace Outer { +//// namespace Inner { +//// function /*1*/lazy(): void; +//// } +//// } + +// @Filename: /index.ts +//// import { /*2*/lazy } from "./mod" +//// /*3*/lazy(); + +verify.baselineFindAllReferences("1", "2", "3"); diff --git a/tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember3.ts b/tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember3.ts new file mode 100644 index 0000000000000..02747015e580d --- /dev/null +++ b/tests/cases/fourslash/findAllRefsEqualExportedNamespaceMember3.ts @@ -0,0 +1,16 @@ +/// + +// @module: commonjs + +// @Filename: /mod.ts +//// export = Ns; +//// +//// namespace Ns { +//// function /*1*/lazy() {} // this *isn't* exported from the namespace +//// } + +// @Filename: /index.ts +//// import { /*2*/lazy } from "./mod" +//// /*3*/lazy(); + +verify.baselineFindAllReferences("1", "2", "3"); diff --git a/tests/cases/fourslash/findAllRefsEqualExportedObjectMember1.ts b/tests/cases/fourslash/findAllRefsEqualExportedObjectMember1.ts new file mode 100644 index 0000000000000..fe2dd8fe5b857 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsEqualExportedObjectMember1.ts @@ -0,0 +1,16 @@ +/// + +// @module: commonjs + +// @Filename: /mod.d.ts +//// const obj = { +//// /*1*/foo: () => "", +//// }; +//// +//// export = obj; + +// @Filename: /index.ts +//// import { /*2*/foo } from "./mod" +//// /*3*/foo(); + +verify.baselineFindAllReferences("1", "2", "3"); diff --git a/tests/cases/fourslash/findAllRefsEqualExportedObjectMember2.ts b/tests/cases/fourslash/findAllRefsEqualExportedObjectMember2.ts new file mode 100644 index 0000000000000..42233515787e2 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsEqualExportedObjectMember2.ts @@ -0,0 +1,18 @@ +/// + +// @module: commonjs + +// @Filename: /mod.d.ts +//// const obj = { +//// nested: { +//// /*1*/foo: () => "", +//// }, +//// }; +//// +//// export = obj.nested; + +// @Filename: /index.ts +//// import { /*2*/foo } from "./mod" +//// /*3*/foo(); + +verify.baselineFindAllReferences("1", "2", "3"); From a0c8911a4b1d256fbdc7ed50e80907fdb2685d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 10 Sep 2025 12:48:04 +0200 Subject: [PATCH 2/4] fix the other thing --- src/services/importTracker.ts | 10 +- ...xportedClassInstanceMember1.baseline.jsonc | 161 ++++++++ ...ultExportedNamespaceMember1.baseline.jsonc | 145 +++++++ ...ultExportedNamespaceMember2.baseline.jsonc | 169 +++++++++ ...ultExportedNamespaceMember3.baseline.jsonc | 66 ++++ ...efaultExportedObjectMember1.baseline.jsonc | 169 +++++++++ ...efaultExportedObjectMember2.baseline.jsonc | 177 +++++++++ ...xportedClassInstanceMember1.baseline.jsonc | 357 ++++++++++++++++++ ...sEqualExportedObjectMember1.baseline.jsonc | 110 +++++- ...sEqualExportedObjectMember2.baseline.jsonc | 110 +++++- ...RefsDefaultExportedClassInstanceMember1.ts | 16 + ...dAllRefsDefaultExportedNamespaceMember1.ts | 16 + ...dAllRefsDefaultExportedNamespaceMember2.ts | 18 + ...dAllRefsDefaultExportedNamespaceMember3.ts | 16 + ...findAllRefsDefaultExportedObjectMember1.ts | 16 + ...findAllRefsDefaultExportedObjectMember2.ts | 18 + ...llRefsEqualExportedClassInstanceMember1.ts | 16 + .../findAllRefsEqualExportedObjectMember1.ts | 2 +- .../findAllRefsEqualExportedObjectMember2.ts | 2 +- 19 files changed, 1581 insertions(+), 13 deletions(-) create mode 100644 tests/baselines/reference/findAllRefsDefaultExportedClassInstanceMember1.baseline.jsonc create mode 100644 tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember1.baseline.jsonc create mode 100644 tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember2.baseline.jsonc create mode 100644 tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember3.baseline.jsonc create mode 100644 tests/baselines/reference/findAllRefsDefaultExportedObjectMember1.baseline.jsonc create mode 100644 tests/baselines/reference/findAllRefsDefaultExportedObjectMember2.baseline.jsonc create mode 100644 tests/baselines/reference/findAllRefsEqualExportedClassInstanceMember1.baseline.jsonc create mode 100644 tests/cases/fourslash/findAllRefsDefaultExportedClassInstanceMember1.ts create mode 100644 tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember1.ts create mode 100644 tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember2.ts create mode 100644 tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember3.ts create mode 100644 tests/cases/fourslash/findAllRefsDefaultExportedObjectMember1.ts create mode 100644 tests/cases/fourslash/findAllRefsDefaultExportedObjectMember2.ts create mode 100644 tests/cases/fourslash/findAllRefsEqualExportedClassInstanceMember1.ts diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 365e59a1d64a3..33c6ff364061e 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -21,6 +21,7 @@ import { getNameOfAccessExpression, getSourceFileOfNode, getSymbolId, + getSymbolTarget, hasSyntacticModifier, Identifier, ImportCall, @@ -637,9 +638,12 @@ export function getImportOrExportSymbol(node: Node, symbol: Symbol, checker: Typ } else { const sourceFile = getSourceFileOfNode(node); - if (sourceFile.symbol.exports?.has(InternalSymbolName.ExportEquals) && checker.resolveExternalModuleSymbol(sourceFile.symbol) === symbol.parent) { - const exportInfo = { exportingModuleSymbol: sourceFile.symbol, exportKind: ExportKind.Named }; - return { kind: ImportExport.Export, symbol, exportInfo }; + if (sourceFile.symbol?.exports?.has(InternalSymbolName.ExportEquals)) { + const moduleSymbol = checker.resolveExternalModuleSymbol(sourceFile.symbol); + if (moduleSymbol && (moduleSymbol === symbol.parent || some(checker.getPropertiesOfType(checker.getTypeOfSymbol(moduleSymbol)), s => getSymbolTarget(s, checker) === symbol))) { + const exportInfo = { exportingModuleSymbol: sourceFile.symbol, exportKind: ExportKind.Named }; + return { kind: ImportExport.Export, symbol, exportInfo }; + } } } } diff --git a/tests/baselines/reference/findAllRefsDefaultExportedClassInstanceMember1.baseline.jsonc b/tests/baselines/reference/findAllRefsDefaultExportedClassInstanceMember1.baseline.jsonc new file mode 100644 index 0000000000000..8089bd1a55d76 --- /dev/null +++ b/tests/baselines/reference/findAllRefsDefaultExportedClassInstanceMember1.baseline.jsonc @@ -0,0 +1,161 @@ +// === findAllReferences === +// === /mod.ts === +// class Cls { +// /*FIND ALL REFS*/<|[|{| isWriteAccess: true, isDefinition: true |}foo|]() {}|> +// }; +// +// export default new Cls(); + +// === /index.ts === +// import def from "./mod" +// def.[|foo|](); + + // === Definitions === + // === /mod.ts === + // class Cls { + // /*FIND ALL REFS*/<|[|foo|]() {}|> + // }; + // + // export default new Cls(); + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "method", + "name": "(method) Cls.foo(): void", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "method", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Cls", + "kind": "className" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "foo", + "kind": "methodName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /mod.ts === +// class Cls { +// <|[|{| isWriteAccess: true |}foo|]() {}|> +// }; +// +// export default new Cls(); + +// === /index.ts === +// import def from "./mod" +// def.[|foo|]/*FIND ALL REFS*/(); + + // === Definitions === + // === /mod.ts === + // class Cls { + // <|[|foo|]() {}|> + // }; + // + // export default new Cls(); + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "method", + "name": "(method) Cls.foo(): void", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "method", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Cls", + "kind": "className" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "foo", + "kind": "methodName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember1.baseline.jsonc b/tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember1.baseline.jsonc new file mode 100644 index 0000000000000..631a17ffa4f59 --- /dev/null +++ b/tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember1.baseline.jsonc @@ -0,0 +1,145 @@ +// === findAllReferences === +// === /mod.d.ts === +// export default React; +// +// declare namespace React { +// <|function /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}lazy|](): void;|> +// } + +// === /index.ts === +// import def from "./mod" +// def.[|lazy|](); + + // === Definitions === + // === /mod.d.ts === + // export default React; + // + // declare namespace React { + // <|function /*FIND ALL REFS*/[|lazy|](): void;|> + // } + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function React.lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "React", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /mod.d.ts === +// export default React; +// +// declare namespace React { +// <|function [|{| isWriteAccess: true |}lazy|](): void;|> +// } + +// === /index.ts === +// import def from "./mod" +// def.[|lazy|]/*FIND ALL REFS*/(); + + // === Definitions === + // === /mod.d.ts === + // export default React; + // + // declare namespace React { + // <|function [|lazy|](): void;|> + // } + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function React.lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "React", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember2.baseline.jsonc b/tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember2.baseline.jsonc new file mode 100644 index 0000000000000..68c0f4cf84bd5 --- /dev/null +++ b/tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember2.baseline.jsonc @@ -0,0 +1,169 @@ +// === findAllReferences === +// === /mod.d.ts === +// export default Outer.Inner; +// +// declare namespace Outer { +// namespace Inner { +// <|function /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}lazy|](): void;|> +// } +// } + +// === /index.ts === +// import def from "./mod" +// def.[|lazy|](); + + // === Definitions === + // === /mod.d.ts === + // export default Outer.Inner; + // + // declare namespace Outer { + // namespace Inner { + // <|function /*FIND ALL REFS*/[|lazy|](): void;|> + // } + // } + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function Outer.Inner.lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Outer", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Inner", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /mod.d.ts === +// export default Outer.Inner; +// +// declare namespace Outer { +// namespace Inner { +// <|function [|{| isWriteAccess: true |}lazy|](): void;|> +// } +// } + +// === /index.ts === +// import def from "./mod" +// def.[|lazy|]/*FIND ALL REFS*/(); + + // === Definitions === + // === /mod.d.ts === + // export default Outer.Inner; + // + // declare namespace Outer { + // namespace Inner { + // <|function [|lazy|](): void;|> + // } + // } + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function Outer.Inner.lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Outer", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Inner", + "kind": "moduleName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember3.baseline.jsonc b/tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember3.baseline.jsonc new file mode 100644 index 0000000000000..f152e00fe3c94 --- /dev/null +++ b/tests/baselines/reference/findAllRefsDefaultExportedNamespaceMember3.baseline.jsonc @@ -0,0 +1,66 @@ +// === findAllReferences === +// === /mod.ts === +// export default Ns; +// +// namespace Ns { +// <|function /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}lazy|]() {}|> // this *isn't* exported from the namespace +// } + + // === Definitions === + // === /mod.ts === + // export default Ns; + // + // namespace Ns { + // <|function /*FIND ALL REFS*/[|lazy|]() {}|> // this *isn't* exported from the namespace + // } + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "function", + "name": "function lazy(): void", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "lazy", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// import def from "./mod" +// def.lazy/*FIND ALL REFS*/(); \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsDefaultExportedObjectMember1.baseline.jsonc b/tests/baselines/reference/findAllRefsDefaultExportedObjectMember1.baseline.jsonc new file mode 100644 index 0000000000000..2680dc2247eee --- /dev/null +++ b/tests/baselines/reference/findAllRefsDefaultExportedObjectMember1.baseline.jsonc @@ -0,0 +1,169 @@ +// === findAllReferences === +// === /mod.ts === +// const obj = { +// /*FIND ALL REFS*/<|[|{| isWriteAccess: true, isDefinition: true |}foo|]: () => ""|>, +// }; +// +// export default obj; + +// === /index.ts === +// import def from "./mod" +// def.[|foo|](); + + // === Definitions === + // === /mod.ts === + // const obj = { + // /*FIND ALL REFS*/<|[|foo|]: () => ""|>, + // }; + // + // export default obj; + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "property", + "name": "(property) foo: () => string", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /mod.ts === +// const obj = { +// <|[|{| isWriteAccess: true |}foo|]: () => ""|>, +// }; +// +// export default obj; + +// === /index.ts === +// import def from "./mod" +// def.[|foo|]/*FIND ALL REFS*/(); + + // === Definitions === + // === /mod.ts === + // const obj = { + // <|[|foo|]: () => ""|>, + // }; + // + // export default obj; + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "property", + "name": "(property) foo: () => string", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsDefaultExportedObjectMember2.baseline.jsonc b/tests/baselines/reference/findAllRefsDefaultExportedObjectMember2.baseline.jsonc new file mode 100644 index 0000000000000..16726b70a4795 --- /dev/null +++ b/tests/baselines/reference/findAllRefsDefaultExportedObjectMember2.baseline.jsonc @@ -0,0 +1,177 @@ +// === findAllReferences === +// === /mod.ts === +// const obj = { +// nested: { +// /*FIND ALL REFS*/<|[|{| isWriteAccess: true, isDefinition: true |}foo|]: () => ""|>, +// }, +// }; +// +// export default obj.nested; + +// === /index.ts === +// import def from "./mod" +// def.[|foo|](); + + // === Definitions === + // === /mod.ts === + // const obj = { + // nested: { + // /*FIND ALL REFS*/<|[|foo|]: () => ""|>, + // }, + // }; + // + // export default obj.nested; + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "property", + "name": "(property) foo: () => string", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ] + } + ] + + + +// === findAllReferences === +// === /mod.ts === +// const obj = { +// nested: { +// <|[|{| isWriteAccess: true |}foo|]: () => ""|>, +// }, +// }; +// +// export default obj.nested; + +// === /index.ts === +// import def from "./mod" +// def.[|foo|]/*FIND ALL REFS*/(); + + // === Definitions === + // === /mod.ts === + // const obj = { + // nested: { + // <|[|foo|]: () => ""|>, + // }, + // }; + // + // export default obj.nested; + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "property", + "name": "(property) foo: () => string", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsEqualExportedClassInstanceMember1.baseline.jsonc b/tests/baselines/reference/findAllRefsEqualExportedClassInstanceMember1.baseline.jsonc new file mode 100644 index 0000000000000..160bd2ed51b96 --- /dev/null +++ b/tests/baselines/reference/findAllRefsEqualExportedClassInstanceMember1.baseline.jsonc @@ -0,0 +1,357 @@ +// === findAllReferences === +// === /mod.ts === +// class Cls { +// /*FIND ALL REFS*/<|[|{| defId: 0, isWriteAccess: true, isDefinition: true |}foo|]() {}|> +// }; +// +// export = new Cls(); + +// === /index.ts === +// <|import { [|{| defId: 1, isWriteAccess: true |}foo|] } from "./mod"|> +// [|{| defId: 1 |}foo|](); + + // === Definitions === + // === /mod.ts === + // class Cls { + // /*FIND ALL REFS*/<|[|{| defId: 0 |}foo|]() {}|> + // }; + // + // export = new Cls(); + + // === /index.ts === + // <|import { [|{| defId: 1 |}foo|] } from "./mod"|> + // foo(); + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "method", + "name": "(method) Cls.foo(): void", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "method", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Cls", + "kind": "className" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "foo", + "kind": "methodName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) (method) foo(): void\nimport foo", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "method", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}foo|] } from "./mod"|> +// [|foo|](); + + // === Definitions === + // === /index.ts === + // <|import { /*FIND ALL REFS*/[|foo|] } from "./mod"|> + // foo(); + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) (method) foo(): void\nimport foo", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "method", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /index.ts === +// <|import { [|{| isWriteAccess: true |}foo|] } from "./mod"|> +// /*FIND ALL REFS*/[|foo|](); + + // === Definitions === + // === /index.ts === + // <|import { [|foo|] } from "./mod"|> + // /*FIND ALL REFS*/foo(); + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) (method) foo(): void\nimport foo", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "method", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsEqualExportedObjectMember1.baseline.jsonc b/tests/baselines/reference/findAllRefsEqualExportedObjectMember1.baseline.jsonc index 1ba3f8631b0b9..7a1b895bfe5a4 100644 --- a/tests/baselines/reference/findAllRefsEqualExportedObjectMember1.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsEqualExportedObjectMember1.baseline.jsonc @@ -1,22 +1,31 @@ // === findAllReferences === -// === /mod.d.ts === +// === /mod.ts === // const obj = { -// /*FIND ALL REFS*/<|[|{| isWriteAccess: true, isDefinition: true |}foo|]: () => ""|>, +// /*FIND ALL REFS*/<|[|{| defId: 0, isWriteAccess: true, isDefinition: true |}foo|]: () => ""|>, // }; // // export = obj; +// === /index.ts === +// <|import { [|{| defId: 1, isWriteAccess: true |}foo|] } from "./mod"|> +// [|{| defId: 1 |}foo|](); + // === Definitions === - // === /mod.d.ts === + // === /mod.ts === // const obj = { - // /*FIND ALL REFS*/<|[|foo|]: () => ""|>, + // /*FIND ALL REFS*/<|[|{| defId: 0 |}foo|]: () => ""|>, // }; // // export = obj; + // === /index.ts === + // <|import { [|{| defId: 1 |}foo|] } from "./mod"|> + // foo(); + // === Details === [ { + "defId": 0, "containerKind": "", "containerName": "", "kind": "property", @@ -75,6 +84,99 @@ "kind": "keyword" } ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) (property) foo: () => string\nimport foo", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + } + ] } ] diff --git a/tests/baselines/reference/findAllRefsEqualExportedObjectMember2.baseline.jsonc b/tests/baselines/reference/findAllRefsEqualExportedObjectMember2.baseline.jsonc index 6ca2478e8cea2..8d7f2bfe7106e 100644 --- a/tests/baselines/reference/findAllRefsEqualExportedObjectMember2.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsEqualExportedObjectMember2.baseline.jsonc @@ -1,26 +1,35 @@ // === findAllReferences === -// === /mod.d.ts === +// === /mod.ts === // const obj = { // nested: { -// /*FIND ALL REFS*/<|[|{| isWriteAccess: true, isDefinition: true |}foo|]: () => ""|>, +// /*FIND ALL REFS*/<|[|{| defId: 0, isWriteAccess: true, isDefinition: true |}foo|]: () => ""|>, // }, // }; // // export = obj.nested; +// === /index.ts === +// <|import { [|{| defId: 1, isWriteAccess: true |}foo|] } from "./mod"|> +// [|{| defId: 1 |}foo|](); + // === Definitions === - // === /mod.d.ts === + // === /mod.ts === // const obj = { // nested: { - // /*FIND ALL REFS*/<|[|foo|]: () => ""|>, + // /*FIND ALL REFS*/<|[|{| defId: 0 |}foo|]: () => ""|>, // }, // }; // // export = obj.nested; + // === /index.ts === + // <|import { [|{| defId: 1 |}foo|] } from "./mod"|> + // foo(); + // === Details === [ { + "defId": 0, "containerKind": "", "containerName": "", "kind": "property", @@ -79,6 +88,99 @@ "kind": "keyword" } ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) (property) foo: () => string\nimport foo", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + } + ] } ] diff --git a/tests/cases/fourslash/findAllRefsDefaultExportedClassInstanceMember1.ts b/tests/cases/fourslash/findAllRefsDefaultExportedClassInstanceMember1.ts new file mode 100644 index 0000000000000..2c2ad8baca094 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsDefaultExportedClassInstanceMember1.ts @@ -0,0 +1,16 @@ +/// + +// @module: commonjs + +// @Filename: /mod.ts +//// class Cls { +//// /*1*/foo() {} +//// }; +//// +//// export default new Cls(); + +// @Filename: /index.ts +//// import def from "./mod" +//// def.foo/*2*/(); + +verify.baselineFindAllReferences("1", "2"); diff --git a/tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember1.ts b/tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember1.ts new file mode 100644 index 0000000000000..87488c0923bfb --- /dev/null +++ b/tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember1.ts @@ -0,0 +1,16 @@ +/// + +// @module: commonjs + +// @Filename: /mod.d.ts +//// export default React; +//// +//// declare namespace React { +//// function /*1*/lazy(): void; +//// } + +// @Filename: /index.ts +//// import def from "./mod" +//// def.lazy/*2*/(); + +verify.baselineFindAllReferences("1", "2"); diff --git a/tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember2.ts b/tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember2.ts new file mode 100644 index 0000000000000..d99ba4f962bf4 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember2.ts @@ -0,0 +1,18 @@ +/// + +// @module: commonjs + +// @Filename: /mod.d.ts +//// export default Outer.Inner; +//// +//// declare namespace Outer { +//// namespace Inner { +//// function /*1*/lazy(): void; +//// } +//// } + +// @Filename: /index.ts +//// import def from "./mod" +//// def.lazy/*2*/(); + +verify.baselineFindAllReferences("1", "2"); diff --git a/tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember3.ts b/tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember3.ts new file mode 100644 index 0000000000000..8d17986575678 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsDefaultExportedNamespaceMember3.ts @@ -0,0 +1,16 @@ +/// + +// @module: commonjs + +// @Filename: /mod.ts +//// export default Ns; +//// +//// namespace Ns { +//// function /*1*/lazy() {} // this *isn't* exported from the namespace +//// } + +// @Filename: /index.ts +//// import def from "./mod" +//// def.lazy/*2*/(); + +verify.baselineFindAllReferences("1", "2"); diff --git a/tests/cases/fourslash/findAllRefsDefaultExportedObjectMember1.ts b/tests/cases/fourslash/findAllRefsDefaultExportedObjectMember1.ts new file mode 100644 index 0000000000000..569943cc24330 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsDefaultExportedObjectMember1.ts @@ -0,0 +1,16 @@ +/// + +// @module: commonjs + +// @Filename: /mod.ts +//// const obj = { +//// /*1*/foo: () => "", +//// }; +//// +//// export default obj; + +// @Filename: /index.ts +//// import def from "./mod" +//// def.foo/*2*/(); + +verify.baselineFindAllReferences("1", "2"); diff --git a/tests/cases/fourslash/findAllRefsDefaultExportedObjectMember2.ts b/tests/cases/fourslash/findAllRefsDefaultExportedObjectMember2.ts new file mode 100644 index 0000000000000..fecdfcffd1887 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsDefaultExportedObjectMember2.ts @@ -0,0 +1,18 @@ +/// + +// @module: commonjs + +// @Filename: /mod.ts +//// const obj = { +//// nested: { +//// /*1*/foo: () => "", +//// }, +//// }; +//// +//// export default obj.nested; + +// @Filename: /index.ts +//// import def from "./mod" +//// def.foo/*2*/(); + +verify.baselineFindAllReferences("1", "2"); diff --git a/tests/cases/fourslash/findAllRefsEqualExportedClassInstanceMember1.ts b/tests/cases/fourslash/findAllRefsEqualExportedClassInstanceMember1.ts new file mode 100644 index 0000000000000..45abc85db284b --- /dev/null +++ b/tests/cases/fourslash/findAllRefsEqualExportedClassInstanceMember1.ts @@ -0,0 +1,16 @@ +/// + +// @module: commonjs + +// @Filename: /mod.ts +//// class Cls { +//// /*1*/foo() {} +//// }; +//// +//// export = new Cls(); + +// @Filename: /index.ts +//// import { /*2*/foo } from "./mod" +//// /*3*/foo(); + +verify.baselineFindAllReferences("1", "2", "3"); diff --git a/tests/cases/fourslash/findAllRefsEqualExportedObjectMember1.ts b/tests/cases/fourslash/findAllRefsEqualExportedObjectMember1.ts index fe2dd8fe5b857..2ad849cab803d 100644 --- a/tests/cases/fourslash/findAllRefsEqualExportedObjectMember1.ts +++ b/tests/cases/fourslash/findAllRefsEqualExportedObjectMember1.ts @@ -2,7 +2,7 @@ // @module: commonjs -// @Filename: /mod.d.ts +// @Filename: /mod.ts //// const obj = { //// /*1*/foo: () => "", //// }; diff --git a/tests/cases/fourslash/findAllRefsEqualExportedObjectMember2.ts b/tests/cases/fourslash/findAllRefsEqualExportedObjectMember2.ts index 42233515787e2..c98b60f0ecfcd 100644 --- a/tests/cases/fourslash/findAllRefsEqualExportedObjectMember2.ts +++ b/tests/cases/fourslash/findAllRefsEqualExportedObjectMember2.ts @@ -2,7 +2,7 @@ // @module: commonjs -// @Filename: /mod.d.ts +// @Filename: /mod.ts //// const obj = { //// nested: { //// /*1*/foo: () => "", From 6c79d27c8ebe4c6b745212c5f1664882260579bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 10 Sep 2025 13:53:57 +0200 Subject: [PATCH 3/4] try with `dontResolveAlias` --- src/compiler/types.ts | 2 +- src/services/importTracker.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 545d908c03258..8043ab8951208 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5460,7 +5460,7 @@ export interface TypeChecker { * * @internal */ - resolveExternalModuleSymbol(symbol: Symbol): Symbol; + resolveExternalModuleSymbol(symbol: Symbol, dontResolveAlias?: boolean): Symbol; /** * @param node A location where we might consider accessing `this`. Not necessarily a ThisExpression. * diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 33c6ff364061e..29af0c4320022 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -639,7 +639,7 @@ export function getImportOrExportSymbol(node: Node, symbol: Symbol, checker: Typ else { const sourceFile = getSourceFileOfNode(node); if (sourceFile.symbol?.exports?.has(InternalSymbolName.ExportEquals)) { - const moduleSymbol = checker.resolveExternalModuleSymbol(sourceFile.symbol); + const moduleSymbol = checker.resolveExternalModuleSymbol(sourceFile.symbol, /*dontResolveAlias*/ true); if (moduleSymbol && (moduleSymbol === symbol.parent || some(checker.getPropertiesOfType(checker.getTypeOfSymbol(moduleSymbol)), s => getSymbolTarget(s, checker) === symbol))) { const exportInfo = { exportingModuleSymbol: sourceFile.symbol, exportKind: ExportKind.Named }; return { kind: ImportExport.Export, symbol, exportInfo }; From 65be4e990a065260a71f1b934e5ebef047105d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 10 Sep 2025 14:04:11 +0200 Subject: [PATCH 4/4] use getMergedSymbol-based comparison in search --- src/compiler/types.ts | 2 +- src/services/findAllReferences.ts | 10 +++++++++- src/services/importTracker.ts | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8043ab8951208..545d908c03258 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5460,7 +5460,7 @@ export interface TypeChecker { * * @internal */ - resolveExternalModuleSymbol(symbol: Symbol, dontResolveAlias?: boolean): Symbol; + resolveExternalModuleSymbol(symbol: Symbol): Symbol; /** * @param node A location where we might consider accessing `this`. Not necessarily a ThisExpression. * diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index a2ed0feb795a7..7320c6d3074f0 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1474,7 +1474,15 @@ export namespace Core { } = searchOptions; const escapedText = escapeLeadingUnderscores(text); const parents = this.options.implementations && location ? getParentSymbolsOfPropertyAccess(location, symbol, this.checker) : undefined; - return { symbol, comingFrom, text, escapedText, parents, allSearchSymbols, includes: sym => contains(allSearchSymbols, sym) }; + return { + symbol, + comingFrom, + text, + escapedText, + parents, + allSearchSymbols, + includes: sym => contains(allSearchSymbols, sym, (s1, s2) => this.checker.getMergedSymbol(s1) === this.checker.getMergedSymbol(s2)), + }; } private readonly symbolIdToReferences: Entry[][] = []; diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 29af0c4320022..33c6ff364061e 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -639,7 +639,7 @@ export function getImportOrExportSymbol(node: Node, symbol: Symbol, checker: Typ else { const sourceFile = getSourceFileOfNode(node); if (sourceFile.symbol?.exports?.has(InternalSymbolName.ExportEquals)) { - const moduleSymbol = checker.resolveExternalModuleSymbol(sourceFile.symbol, /*dontResolveAlias*/ true); + const moduleSymbol = checker.resolveExternalModuleSymbol(sourceFile.symbol); if (moduleSymbol && (moduleSymbol === symbol.parent || some(checker.getPropertiesOfType(checker.getTypeOfSymbol(moduleSymbol)), s => getSymbolTarget(s, checker) === symbol))) { const exportInfo = { exportingModuleSymbol: sourceFile.symbol, exportKind: ExportKind.Named }; return { kind: ImportExport.Export, symbol, exportInfo };