bito-code-review[bot] commented on code in PR #35931:
URL: https://github.com/apache/superset/pull/35931#discussion_r2481848653
##########
superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts:
##########
@@ -69,15 +70,21 @@ export const useUnsavedChangesPrompt = ({
}, [onSave]);
const blockCallback = useCallback(
- ({ pathname }: { pathname: string }) => {
+ ({
+ pathname,
+ state,
+ }: {
+ pathname: Location['state'];
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Incorrect blockCallback parameter types</b></div>
<div id="fix">
The type annotations for the `blockCallback` parameters are swapped:
`pathname` is incorrectly typed as `Location['state']` (which is `any`) and
`state` as `Path['pathname']` (which is `string`), but according to the
`history` package types, `pathname` should be `string` and `state` should be
`any`. This violates TypeScript type safety and the project's rule against
improper `any` usage where avoidable, potentially causing runtime type
mismatches during navigation blocking. The `history.push(pathname, state)` call
downstream in `confirmNavigationRef` would receive incorrectly typed values,
breaking navigation functionality. Correcting the types ensures the callback
properly handles the location object from `history.block`.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
- const blockCallback = useCallback(
- ({
- pathname,
- state,
- }: {
- pathname: Location['state'];
- state: Path['pathname'];
- }) => {
+ const blockCallback = useCallback(
+ ({
+ pathname,
- state,
+ }: {
+ pathname: string;
+ state: any;
+ }) => {
```
</div>
</details>
</div>
<details>
<summary><b>Citations</b></summary>
<ul>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/b59ac4d/.cursor/rules/dev-standard.mdc#L16">dev-standard.mdc:16</a>
</li>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/b59ac4d/AGENTS.md#L57">AGENTS.md:57</a>
</li>
</ul>
</details>
<small><i>Code Review Run <a
href=https://github.com/apache/superset/pull/35931#issuecomment-3473626599>#29e13f</a></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]