diff --git a/doc/reference/app.md b/doc/reference/app.md index 0e189db1..31a4d059 100644 --- a/doc/reference/app.md +++ b/doc/reference/app.md @@ -61,6 +61,8 @@ The `config` object is an object with some of the following keys: templates (see [translations](translations.md)) - **`templates (string | xml document)`**: all the templates that will be used by the components created by the application. +- **`warnIfNoStaticProps (boolean, default=false)`**: if true, Owl will log a warning + whenever it encounters a component that does not provide a [static props description](props.md#props-validation). ## `mount` helper diff --git a/src/app/app.ts b/src/app/app.ts index cc5fcdff..b1a93777 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -16,6 +16,7 @@ export interface AppConfig
extends TemplateSetConfig { props?: P; env?: E; test?: boolean; + warnIfNoStaticProps?: boolean; } let hasBeenLogged = false; @@ -41,6 +42,7 @@ export class App< env: E; scheduler = new Scheduler(); root: ComponentNode
| null = null; + warnIfNoStaticProps: boolean; constructor(Root: ComponentConstructor
, config: AppConfig
= {}) {
super(config);
@@ -48,6 +50,7 @@ export class App<
if (config.test) {
this.dev = true;
}
+ this.warnIfNoStaticProps = config.warnIfNoStaticProps || false;
if (this.dev && !config.test && !hasBeenLogged) {
console.info(DEV_MSG());
hasBeenLogged = true;
@@ -61,7 +64,7 @@ export class App<
mount(target: HTMLElement, options?: MountOptions): Promise (name: string | ComponentConstructor , props:
const schema = ComponentClass.props;
if (!schema) {
+ if (parent.__owl__.app.warnIfNoStaticProps) {
+ console.warn(`Component '${ComponentClass.name}' does not have a static props description`);
+ }
return;
}
const defaultProps = ComponentClass.defaultProps;
diff --git a/tests/app/__snapshots__/app.test.ts.snap b/tests/app/__snapshots__/app.test.ts.snap
index eb49badc..6945d47a 100644
--- a/tests/app/__snapshots__/app.test.ts.snap
+++ b/tests/app/__snapshots__/app.test.ts.snap
@@ -41,3 +41,17 @@ exports[`app destroy remove the widget from the DOM 1`] = `
}
}"
`;
+
+exports[`app warnIfNoStaticProps works as expected 1`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
+
+ let block1 = createBlock(\`