[IMP] component: display nice error for wrong child component

If you declare a child component which is not actually a Component,
the error message is not very friendly and not very helpfull to find
what happens and which child component is wrong.

```
const ChildComponent = "not a component constructor";

class MyComponent extends Component {
    static components = { ChildComponent };
}
```

This commit improves the type declaration for those working with Typescript
and adds a runtime check for javascript codebases
This commit is contained in:
Lucas Lefèvre
2022-05-06 16:39:07 +02:00
committed by Géry Debongnie
parent d09771b04b
commit 5c71744e19
4 changed files with 33 additions and 0 deletions
@@ -1,5 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`basics display a nice error if a component is not a component 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return component(\`SomeComponent\`, {}, key + \`__1\`, node, ctx);
}
}"
`;
exports[`basics display a nice error if it cannot find component (in dev mode) 1`] = `
"function anonymous(bdom, helpers
) {