Open Arcasias opened 7 months ago
Use type markers to ensure type safety in components' XML templates (e.g. <expression>:<type>="value"). This would only be applied in dev or test mode and would throw an error if the evaluated expression does not return the intended type.
<expression>:<type>="value"
class Root extends Component { static props = {}; static template = xml` <div t-att-class:string="className"> Value <t t-esc:number="state.value" /> <button t-on-click:function="onClick">Increment</button> </div> `; className = "my-class"; setup() { this.state = reactive({ value: 0 }); } onClick() { this.state.value++; } }
Proposition
Use type markers to ensure type safety in components' XML templates (e.g.
<expression>:<type>="value"
). This would only be applied in dev or test mode and would throw an error if the evaluated expression does not return the intended type.Example