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:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
// WRN editor language server source hash: 047a3b701a20619b02c7dacecdb3af63e2989e1837abbc83c8b235981f694562
|
||||
// WRN editor language server source hash: 8f158f0d23d75de9b08a12cef6e20d2e5cdb48b6242db3b724634880277acd8c
|
||||
// WRN editor language server generator hash: f593a44aaf05495b789ce7a3086bee1eebb951b884d41c0e017bbcfe5f547e72
|
||||
// @bun @bun-cjs
|
||||
(function(exports, require, module, __filename, __dirname) {var __create = Object.create;
|
||||
@@ -172681,7 +172681,7 @@ function componentContract(ast) {
|
||||
`);
|
||||
const outputs = ast.outputs.map((output) => ` ${safe(output.name)}(${output.payload ? `${output.payload.name}${output.payload.optional ? "?" : ""}: ${output.payload.valueType}` : ""}): void;`).join(`
|
||||
`);
|
||||
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")};`).join(`
|
||||
const callable = ast.runtimeFunctions.map((fn) => ` ${safe(fn.name)}(${fn.parameters.map((param) => `${param.name}${param.optional ? "?" : ""}: ${param.valueType ?? "unknown"}`).join(", ")}): ${fn.returnType ?? (fn.async ? "Promise<unknown>" : "unknown")};`).join(`
|
||||
`);
|
||||
return `${typeSource ? `${typeSource}
|
||||
|
||||
@@ -172960,7 +172960,7 @@ function virtualTypeScriptModule(source, filePath = "component.wrn", appRoot = f
|
||||
append(ast.kind === "global-store" || ast.kind === "page-store" ? storeContract(ast) : componentContract(ast));
|
||||
append(importedWrnDeclarations(ast, filePath, appRoot));
|
||||
const sharedNames = new Set(ast.runtimeFunctions.filter((fn) => fn.runtime === "shared").map((fn) => fn.name));
|
||||
for (const runtime of ["shared", "client", "server", "legacy"]) {
|
||||
for (const runtime of ["shared", "client", "server"]) {
|
||||
const functions = ast.runtimeFunctions.filter((fn) => fn.runtime === runtime);
|
||||
if (!functions.length)
|
||||
continue;
|
||||
|
||||
@@ -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")};`,
|
||||
|
||||
@@ -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"');
|
||||
});
|
||||
Reference in New Issue
Block a user