[IMP] runtime: allow using any class as a type in props validation

Previously, we had a fixed whitelist for types that were allowed during
props validation. The implementation however supports using arbitrary
classes, and in practice it's desirable to do so, and already done when
not using typescript (when using typescript, it will error if the class
is not whitelisted), eg in Odoo, we use "Element" for the arch in the
standard view props, but this causes all view controllers to fail type
checking because it's not whitelisted.

This commit simply replaces existing constructors by a generic
constructor type, and adds a test with a validation success and a test
with a validation failure.
This commit is contained in:
Samuel Degueldre
2024-03-26 13:52:43 +01:00
committed by Géry Debongnie
parent 33dfeb1b41
commit 97b69f164f
3 changed files with 86 additions and 10 deletions
+1 -10
View File
@@ -1,16 +1,7 @@
import { OwlError } from "../common/owl_error";
import { toRaw } from "./reactivity";
type BaseType =
| typeof String
| typeof Boolean
| typeof Number
| typeof Date
| typeof Object
| typeof Array
| typeof Function
| true
| "*";
type BaseType = { new (...args: any[]): any } | true | "*";
interface TypeInfo {
type?: TypeDescription;