Repository navigation
fix(vue): preserve runtime props declarations in pages patchProps - #589
Merged
Merged
Conversation
Fixes voidzero-dev#557 ## Summary Vue Pages generated `patchProps` assigned `comp.props = Object.keys(props)`, which replaced components that already declare runtime props and dropped defaults, required flags, validators, and types. The `__voidPatched` guard then froze that stripped declaration. ## Changes - Add `hasRuntimePropsDeclaration()` in generated SSR and client bundles before patching. - Skip overwriting `comp.props` when the component already has a non-empty runtime declaration. - Keep registering prop keys from page data only for type-only `defineProps<T>()` components that lack runtime props metadata. - Deduplicate the injected helper via `PATCH_PROPS_RUNTIME` in `plugin-pages.ts`. - Add unit tests that execute the generated `patchProps` from renderer and client modules. ## Testing - `pnpm exec vp test run packages/vue/test/unit/plugin-pages.test.ts` - `pnpm exec vp run --filter ./packages/vue typecheck` Co-authored-by: froQ <sayhola@froq.me>
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 #557
Summary
Vue Pages generated
patchPropsassignedcomp.props = Object.keys(props), which replaced components that already declare runtime props and dropped defaults, required flags, validators, and types. The__voidPatchedguard then froze that stripped declaration.Changes
hasRuntimePropsDeclaration()in generated SSR and client bundles before patching.comp.propswhen the component already has a non-empty runtime declaration.defineProps<T>()components that lack runtime props metadata.PATCH_PROPS_RUNTIMEinplugin-pages.ts.patchPropsfrom renderer and client modules.Testing
pnpm exec vp test run packages/vue/test/unit/plugin-pages.test.tspnpm exec vp run --filter ./packages/vue typecheck