fix(javascript): preserve import-equals declaration and export evidence (#2062)

* fix(javascript): retain TypeScript import-equals dependencies

* test(mcp): align completion checks with warm provider state

* fix(javascript): propagate require origins through exported aliases

* fix(javascript): normalize equivalent CTS binding origins

---------

Co-authored-by: hhang <169027046+xu91102@users.noreply.github.com>
This commit is contained in:
hhangandhhang authored and GitHub committed 2026-10-13 06:04:21 +09:00
1 parent 6ce5903e7a
commit 86fab11fbe
16 files changed
+498 -48

No files matched your search

@@ -52,6 +52,36 @@ describe("TypeScript import-equals links", () => {
});
describe("CommonJS dependency links", () => {
it("retains an import-equals binding and its module origin", () => {
const ir = analyzeJavaScriptSemantics(`
import typed = require("dependency");
import type TypeOnly = require("type-only");
namespace Local { export class Marker {} }
import Alias = Local.Marker;
void typed;
`);
expect(topLevelBinding(ir, "typed")).toMatchObject({
kind: "import",
mutable: false,
provenance: {
origins: [{ specifier: "dependency", importedPath: [] }],
},
});
expect(
ir.moduleLinks.filter(({ specifier }) => specifier !== null),
).toEqual([
expect.objectContaining({
kind: "require",
specifier: "dependency",
importedName: null,
localName: "typed",
}),
]);
expect(ir.references.filter(({ name }) => name === "typed")).toHaveLength(
1,
);
});
it.each([
'require("dependency");',
'void require("dependency");',
@@ -148,7 +178,9 @@ describe("CommonJS dependency links", () => {
]);
expect(
ir.bindings.find(({ name }) => name === "bound")?.provenance.origins,
).toEqual([{ specifier: "bound", importedPath: [] }]);
).toEqual([
{ specifier: "bound", importedPath: [], resolutionMode: "require" },
]);
});
it.each([
@@ -179,6 +211,7 @@ it("preserves unshadowed require origins through aliases and assignments", () =>
expect(origin(topLevelBinding(ir, name))).toEqual({
specifier: "electron",
importedPath: ["ipcMain"],
resolutionMode: "require",
});
expect(topLevelBinding(ir, "assigned").provenance).toMatchObject({
status: "ambiguous",