fix(compiler): reject malformed structured props

This commit is contained in:
2026-08-09 13:24:18 +05:30
parent 91e8b2ab05
commit 8ef6233ef3
3 changed files with 35 additions and 32 deletions
+11
View File
@@ -526,6 +526,17 @@ component NativeProps {
);
});
test("malformed structured prop strings fail with the prop name", async () => {
const mod = await compileAndImport(`component StructuredProps {
props { items = [] options = {} }
view { <div></div> }
}`);
const render = mod.render as (props?: Record<string, unknown>) => string;
expect(() => render({ items: "not-json" })).toThrow("Expected an array prop 'items'");
expect(() => render({ options: "[]" })).toThrow("Expected an object prop 'options'");
});
test("parses a layout block", () => {
const ast = parse(`
layout AppLayout {