release: prepare WRNexusJS 0.8.8
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/typecheck",
|
||||
"version": "0.8.7",
|
||||
"version": "0.8.8",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
@@ -239,6 +239,10 @@ export function virtualTypeScriptModule(
|
||||
|
||||
append(retainedImports(ast), ast.imports[0]);
|
||||
append(ast.types.join("\n\n"), ast.types[0]?.trim());
|
||||
// Pages, components, and stores are rendered with the framework request
|
||||
// context in scope. Mirror the compiler-generated function parameter here so
|
||||
// expressions such as `state user = ctx.user` type-check in the editor.
|
||||
append('declare const ctx: import("@wrnexus/core").Context;');
|
||||
|
||||
for (const prop of ast.props) {
|
||||
// JavaScript keywords such as the conventional `class` component prop are
|
||||
|
||||
@@ -73,3 +73,15 @@ test("treats omitted runtime parameter types as dynamic JavaScript values", () =
|
||||
);
|
||||
expect(diagnostics.filter((diagnostic) => diagnostic.code.startsWith("WRN-TYPE-"))).toEqual([]);
|
||||
});
|
||||
|
||||
test("provides the framework context to page state expressions", () => {
|
||||
const root = app();
|
||||
const diagnostics = checkWrnSource(
|
||||
`page AccountPage {
|
||||
state user = ctx.user
|
||||
view { <main></main> }
|
||||
}`,
|
||||
{ appRoot: root, filePath: join(root, "app", "pages", "account.wrn") },
|
||||
);
|
||||
expect(diagnostics.some((diagnostic) => diagnostic.code === "WRN-TYPE-2304")).toBe(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user