-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix(ui): defensive indexed access in getItemIndexAtPosition #93900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🔍 Existing Issues For ReviewYour pull request is modifying functions with the following pre-existing issues: 📄 File: static/app/components/searchQueryBuilder/hooks/useSelectOnDrag.tsx
Did you find this useful? React with a 👍 or 👎 |
const key = keys[i]!; | ||
const coords = coordinates[key]!; | ||
for (const [i, key] of keys.entries()) { | ||
const coords = coordinates[key]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why we need to allow non block returns :P
const coords = coordinates[key]; | |
const coords = coordinates[key]; | |
if(!coords) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (let i = 0; i < keys.length; i++) { | ||
const key = keys[i]!; | ||
const coords = coordinates[key]!; | ||
for (const [i, key] of keys.entries()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how the rest of the logic works here, but the return value is now no longer guaranteed to be an integer return type, and I don't know if that is something that breaks anything down the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the return value is now no longer guaranteed to be an integer return type
why not? TypeScript still infers the return type as number
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can return -1
if keys
is empty but that was the same before as well...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the return value is now no longer guaranteed to be an integer return type
why not? TypeScript still infers the return type as
number
🤔
I didn't see that the types still infer an int. That's fine with me then, my intention was to highlight that we used to enforce this at runtime before
fixes JAVASCRIPT-31AG