fix(compiler): reject malformed structured props
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user