Typed `this` inside JS patches
patch() extensions now type `this` as the patched object, so editors complete and type-check the target's members. `super` stays untyped.
patch() extensions now type `this` as the patched object, so editors complete and type-check the target's members. `super` stays untyped.
| Branch | Pull request | Commit |
|---|---|---|
| 20.0 | odoo/odoo#289631 ↗ | a9e3b70327 ↗ |
[IMP] web: type `this` inside patch extensions Annotate the `extension` parameter with `ThisType<T & U>` so that `this` inside a patch resolves to the patched object (target plus extension) rather than to the extension literal alone. Patch authors then get completion and type checking on the target's members. `super` cannot be covered the same way: TypeScript always resolves `super` in an object literal method to `any`, whatever the contextual type, so no annotation can reach it. Typing it would mean passing the original as a named value, i.e. changing the `patch` API and every call site, which is not worth it here.