).toMatch(`foo: { type: Number`)
})
+ // #8148
+ test('should not override local bindings', () => {
+ const { bindings } = compile(`
+ <script setup lang="ts">
+ import { computed } from 'vue'
+ defineProps<{ bar: string }>()
+ const bar = computed(() => 1)
+ </script>
+ `)
+ expect(bindings).toStrictEqual({
+ bar: BindingTypes.SETUP_MAYBE_REF,
+ computed: BindingTypes.SETUP_CONST
+ })
+ })
+
describe('errors', () => {
test('w/ both type and non-type args', () => {
expect(() => {
// register bindings
if (ctx.propsRuntimeDecl) {
for (const key of getObjectOrArrayExpressionKeys(ctx.propsRuntimeDecl)) {
- ctx.bindingMetadata[key] = BindingTypes.PROPS
+ if (!(key in ctx.bindingMetadata)) {
+ ctx.bindingMetadata[key] = BindingTypes.PROPS
+ }
}
}
for (const prop of props) {
propStrings.push(genRuntimePropFromType(ctx, prop, hasStaticDefaults))
// register bindings
- ctx.bindingMetadata[prop.key] = BindingTypes.PROPS
+ if (!(prop.key in ctx.bindingMetadata)) {
+ ctx.bindingMetadata[prop.key] = BindingTypes.PROPS
+ }
}
let propsDecls = `{