File tree 2 files changed +21
-2
lines changed
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -571,6 +571,21 @@ const props = defineProps({ foo: String })
571
571
) . toMatch ( `foo: { type: Number` )
572
572
} )
573
573
574
+ // #8148
575
+ test ( 'should not override local bindings' , ( ) => {
576
+ const { bindings } = compile ( `
577
+ <script setup lang="ts">
578
+ import { computed } from 'vue'
579
+ defineProps<{ bar: string }>()
580
+ const bar = computed(() => 1)
581
+ </script>
582
+ ` )
583
+ expect ( bindings ) . toStrictEqual ( {
584
+ bar : BindingTypes . SETUP_MAYBE_REF ,
585
+ computed : BindingTypes . SETUP_CONST
586
+ } )
587
+ } )
588
+
574
589
describe ( 'errors' , ( ) => {
575
590
test ( 'w/ both type and non-type args' , ( ) => {
576
591
expect ( ( ) => {
Original file line number Diff line number Diff line change @@ -58,7 +58,9 @@ export function processDefineProps(
58
58
// register bindings
59
59
if ( ctx . propsRuntimeDecl ) {
60
60
for ( const key of getObjectOrArrayExpressionKeys ( ctx . propsRuntimeDecl ) ) {
61
- ctx . bindingMetadata [ key ] = BindingTypes . PROPS
61
+ if ( ! ( key in ctx . bindingMetadata ) ) {
62
+ ctx . bindingMetadata [ key ] = BindingTypes . PROPS
63
+ }
62
64
}
63
65
}
64
66
@@ -170,7 +172,9 @@ function genRuntimePropsFromTypes(ctx: ScriptCompileContext) {
170
172
for ( const prop of props ) {
171
173
propStrings . push ( genRuntimePropFromType ( ctx , prop , hasStaticDefaults ) )
172
174
// register bindings
173
- ctx . bindingMetadata [ prop . key ] = BindingTypes . PROPS
175
+ if ( ! ( prop . key in ctx . bindingMetadata ) ) {
176
+ ctx . bindingMetadata [ prop . key ] = BindingTypes . PROPS
177
+ }
174
178
}
175
179
176
180
let propsDecls = `{
You can’t perform that action at this time.
0 commit comments