fix(compiler-sfc): fix usage detection for types in v-for/v-slot expressions

fix #5959
This commit is contained in:
Evan You
2022-05-21 00:09:15 +08:00
parent 8ba0bb8ec3
commit 583b625987
3 changed files with 20 additions and 6 deletions

View File

@@ -722,7 +722,7 @@ return { props, a, emit }
exports[`SFC compile <script setup> dev mode import usage check TS annotations 1`] = `
"import { defineComponent as _defineComponent } from 'vue'
import { Foo, Bar, Baz } from './x'
import { Foo, Bar, Baz, Qux, Fred } from './x'
export default /*#__PURE__*/_defineComponent({
setup(__props, { expose }) {

View File

@@ -446,7 +446,7 @@ defineExpose({ foo: 123 })
test('TS annotations', () => {
const { content } = compile(`
<script setup lang="ts">
import { Foo, Bar, Baz } from './x'
import { Foo, Bar, Baz, Qux, Fred } from './x'
const a = 1
function b() {}
</script>
@@ -454,6 +454,8 @@ defineExpose({ foo: 123 })
{{ a as Foo }}
{{ b<Bar>() }}
{{ Baz }}
<Comp v-slot="{ data }: Qux">{{ data }}</Comp>
<div v-for="{ z = x as Qux } in list as Fred"/>
</template>
`)
expect(content).toMatch(`return { a, b, Baz }`)