fix(core): _restProps falls back to plain-object copy for non-props inputs - #8897
Open
blakeley wants to merge 1 commit into
Open
fix(core): _restProps falls back to plain-object copy for non-props inputs#8897blakeley wants to merge 1 commit into
blakeley wants to merge 1 commit into
Conversation
…nputs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: b68b1bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #8894
Problem
The optimizer emits
_restPropsfor any rest destructure it hoists into a QRL segment, not just component prop destructures. ArouteLoader$such as:is compiled to
_restProps(await fetchThing(), ["secret"])(visible in the SSR transform output of the repro below).But
_restPropsonly knew how to read the_VAR_PROPS/_CONST_PROPSsymbols, which exist solely on component props proxies. Given a plain object neither symbol is present, both loops iterate nothing, and the helper returns an empty props proxy. The rest object silently loses every key — no error, no warning, just missing data in the loader payload.Fix
_restPropsnow detects a non-props input (both_VAR_PROPSand_CONST_PROPSareundefined) and falls back to native rest-destructure semantics: copy the input's own enumerable keys, minus the omit list, intotargetand returntargetitself — a plain object, not a props proxy.The existing props-proxy path is untouched, so there is no behavior change for component props.
Repro
Minimal reproduction: https://github.com/blakeley/restprops-plain-object-empty
Tests
Added
packages/qwik/src/core/shared/utils/prop.unit.tswith four cases, all of which fail onmainand pass with the fix:{a:1,b:2,c:3}with omit["a"]→{b:2,c:3}targetis written into and returnedThe full
packages/qwik/src/corevitest suite is green (2057 passed).