feat: remove $.unwrap
calls from each block indexes
#12640
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #12511 and #12530 for more context.
At present, we unnecessarily wrap each block indexes in
unwrap
:We know that
i
is a number, here;$.unwrap(i)
is unnecessary. In the case of a keyed block, we can use$.get(i)
. And in the rare case that a key function references the index, we can always just reference it (and the item) directly.We shouldn't be using
$.unwrap
anyway because duck typing doesn't work (I guess we could faff around with a private symbol, but let's not) — this PR doesn't kill it off completely but it gets us part of the way there. Will work on that in a follow-up PR.I didn't include a snapshot test, because when we remove
unwrap
from the codebase it'll no longer be necessary.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint