fix(compiler-sfc): fix local var access check for bindings in normal script

fix #4644
This commit is contained in:
Evan You
2021-09-22 10:10:20 -04:00
parent 2476eaad6e
commit 6d6cc90912
2 changed files with 24 additions and 4 deletions

View File

@@ -1181,6 +1181,19 @@ const emit = defineEmits(['a', 'b'])
defineEmits([bar])
</script>`)
).toThrow(`cannot reference locally declared variables`)
// #4644
expect(() =>
compile(`
<script>const bar = 1</script>
<script setup>
defineProps({
foo: {
default: () => bar
}
})
</script>`)
).not.toThrow(`cannot reference locally declared variables`)
})
test('should allow defineProps/Emit() referencing scope var', () => {