fix(typecheck): drop legacy FunctionRuntime branches in contracts/index

Fix round 1 for task 1: packages/typecheck also branched on the
removed legacy runtime (componentContract's exclusion filter and the
runtime-namespace loop). Removes both, adds a regression test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-20 00:51:21 +05:30
co-authored by Claude Opus 5
parent ec63090006
commit b7796b103a
4 changed files with 32 additions and 5 deletions
-1
View File
@@ -22,7 +22,6 @@ export function componentContract(ast: PageAst): string {
)
.join("\n");
const callable = ast.runtimeFunctions
.filter((fn) => fn.runtime !== "legacy")
.map(
(fn) =>
` ${safe(fn.name)}(${fn.parameters.map((param) => `${param.name}${param.optional ? "?" : ""}: ${param.valueType ?? "unknown"}`).join(", ")}): ${fn.returnType ?? (fn.async ? "Promise<unknown>" : "unknown")};`,
+1 -1
View File
@@ -300,7 +300,7 @@ export function virtualTypeScriptModule(
const sharedNames = new Set(
ast.runtimeFunctions.filter((fn) => fn.runtime === "shared").map((fn) => fn.name),
);
for (const runtime of ["shared", "client", "server", "legacy"] as const) {
for (const runtime of ["shared", "client", "server"] as const) {
const functions = ast.runtimeFunctions.filter((fn) => fn.runtime === runtime);
if (!functions.length) continue;
const localNames = new Set(functions.map((fn) => fn.name));
@@ -0,0 +1,28 @@
import { expect, test } from "bun:test";
import { parse } from "@wrnexus/syntax";
import { componentContract, virtualTypeScriptModule } from "../src/index.ts";
const SOURCE = `component Probe {
functions {
function unmarkedHelper(): string {
return "both";
}
}
view { <main>x</main> }
}
`;
test("componentContract includes an unmarked function in the generated Functions interface", () => {
const ast = parse(SOURCE);
const contract = componentContract(ast);
expect(contract).toContain("unmarkedHelper");
});
test("generated declarations place an unmarked function in the shared namespace, not a legacy one", () => {
const module = virtualTypeScriptModule(SOURCE, "component.wrn");
expect(module.code).toContain("namespace __wrn_shared");
expect(module.code).not.toContain("__wrn_legacy");
expect(module.code).not.toContain('"legacy"');
});