bito-code-review[bot] commented on code in PR #40866:
URL: https://github.com/apache/superset/pull/40866#discussion_r3376675181
##########
superset-websocket/spec/index.test.ts:
##########
@@ -313,7 +367,9 @@ describe('server', () => {
test('success with results', async () => {
mockRedisXrange.mockResolvedValueOnce(streamReturnValue);
- const cb = jest.fn();
+ const cb = jest.fn() as jest.MockedFunction<
+ (results: server.StreamResult[]) => void
+ >;
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Type mismatch in mock annotation</b></div>
<div id="fix">
The typed mock for `cb` omits `| Promise<void>` that `ListenerFunction`
(src/index.ts:47) declares as its return type. Since `await listener(...)` is
used (src/index.ts:222, 261), callers passing async listeners would be
incorrectly typed. Align the mock signature with the actual `ListenerFunction`
contract.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
--- superset-websocket/spec/index.test.ts (lines 370-372, 389-391, 408-410)
---
370: - const cb = jest.fn() as jest.MockedFunction<
371: - (results: server.StreamResult[]) => void
372: - >;
372: + const cb = jest.fn() as jest.MockedFunction<
373: + (results: server.StreamResult[]) => void | Promise<void>
374: + >;
389: - const cb = jest.fn() as jest.MockedFunction<
390: - (results: server.StreamResult[]) => void
391: - >;
391: + const cb = jest.fn() as jest.MockedFunction<
392: + (results: server.StreamResult[]) => void | Promise<void>
393: + >;
408: - const cb = jest.fn() as jest.MockedFunction<
409: - (results: server.StreamResult[]) => void
410: - >;
410: + const cb = jest.fn() as jest.MockedFunction<
411: + (results: server.StreamResult[]) => void | Promise<void>
412: + >;
```
</div>
</details>
</div>
<small><i>Code Review Run #ba5bcd</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]