diff --git a/src/component.ts b/src/component.ts index d8502c7..42bffd4 100644 --- a/src/component.ts +++ b/src/component.ts @@ -265,8 +265,14 @@ class LoopComponent extends Component { parent, destroyed ); - const returned: (keyof O)[] = Object.keys(output); - for (const name of returned) { + const needed = Object.keys(placeholderObject); + for (const name of needed) { + if (name === "destroyed") { + continue; + } + if (output[name] === undefined) { + throw new Error(`The property ${name} is missing.`); + } placeholderObject[name].replaceWith(output[name]); } return { available: output, output: {} }; diff --git a/test/component.spec.ts b/test/component.spec.ts index d52741f..a558c4f 100644 --- a/test/component.spec.ts +++ b/test/component.spec.ts @@ -272,6 +272,16 @@ describe("component specs", () => { expect(dom).to.have.length(0); expect(toplevel).to.equal(true); }); + it("throws helpful error is a reactive is missing", () => { + const c = loop((props: { foo: H.Behavior }) => { + // Access something that isn't there + (props as any).bar; + return div([dynamic(props.foo)]).output((_) => ({ + foo: H.Behavior.of("foo") + })); + }); + assert.throws(() => testComponent(c), /bar/); + }); }); });