fix(javascript): separate erased types from runtime semantics

Record erasure during definition indexing and reuse it across runtime references, captures, effects, module links, routes, Electron and Vite. Preserve source type links and emitted decorator and computed-key effects; keep actual runtime reads and escapes conservative.

Validation: 1,647 focused tests and 9 documentation tests passed, with build, static and documentation gates. The inherited reference-lifetimes stress file exhausts a 512 MiB worker on both unmodified 18451e479 and this change; that file remains unverified. TypeScript 7.0.2 emit was inspected for ES2022 and ES2018 without executing emitted code.
This commit is contained in:
morluto committed 2026-10-24 18:00:43 +08:00
1 parent cab78de506
commit 89006609f1
32 files changed
+756 -328

No files matched your search

@@ -84,6 +84,29 @@ describe("Vite preload dependency recovery", () => {
).toEqual(["./original.js"]);
});
it.each([
["type DependencyHelper = typeof __vite__mapDeps;", "./original.js"],
["const labels = { __vite__mapDeps() {} };", "./original.js"],
["const labels = { [__vite__mapDeps]: true };", null],
["const dependencyTable = __vite__mapDeps.f;", null],
])(
"distinguishes an erased type query from a runtime helper escape: %s",
(read, expected) => {
const analysis = analyzeJavaScriptStaticSource(`
const __vite__mapDeps = (indexes, map = __vite__mapDeps, dependencies =
(map.f || (map.f = ["./original.js"]))) =>
indexes.map((index) => dependencies[index]);
${read}
__vite__mapDeps([0]);
`);
expect(
analysis.references
.filter(({ kind }) => kind === "dynamic-import")
.map(({ specifier }) => specifier),
).toEqual([expected]);
},
);
it("keeps table slots from a spread onward unknown", () => {
const analysis = analyzeJavaScriptStaticSource(`
const __vite__mapDeps = (indexes, map = __vite__mapDeps, dependencies =