Skip to content

Commit

Permalink
[IMP] congif: enables type checking for binded functions
Browse files Browse the repository at this point in the history
Task Description

Currently all binded function are type as any. This change aims to
for type checking on binded function in TypeScript.

Related Task/PR

Task-3344661

closes #2525

X-original-commit: 360a22f
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
  • Loading branch information
anhe-odoo committed Jun 1, 2023
1 parent eaa83fc commit da501aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 12 additions & 2 deletions tests/components/context_menu.test.ts
Expand Up @@ -132,13 +132,23 @@ const subMenu: FullMenuItem[] = [
];

const originalGetBoundingClientRect = HTMLDivElement.prototype.getBoundingClientRect;
// @ts-ignore the mock should return a complete DOMRect, not only { top, left }
jest
.spyOn(HTMLDivElement.prototype, "getBoundingClientRect")
.mockImplementation(function (this: HTMLDivElement) {
const menu = this.className.includes("o-menu");
if (menu) {
return getPosition(this);
const position = getPosition(this);
return {
top: position.top,
left: position.left,
bottom: position.top + this.clientHeight,
right: position.left + this.clientWidth,
width: this.clientWidth,
height: this.clientHeight,
x: position.left,
y: position.top,
toJSON: () => "",
};
}
return originalGetBoundingClientRect.call(this);
});
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Expand Up @@ -17,7 +17,8 @@
"esModuleInterop": true,
"allowJs": true,
"preserveWatchOutput": true,
"sourceMap": true
"sourceMap": true,
"strictBindCallApply": true
},
"include": ["src"],
"typedocOptions": {
Expand Down

0 comments on commit da501aa

Please sign in to comment.