fix(compiler-sfc): fix template usage check false positives on types
fix #5414
This commit is contained in:
@@ -535,6 +535,23 @@ 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'
|
||||
|
||||
export default /*#__PURE__*/_defineComponent({
|
||||
setup(__props, { expose }) {
|
||||
expose();
|
||||
|
||||
const a = 1
|
||||
function b() {}
|
||||
|
||||
return { a, b, Baz }
|
||||
}
|
||||
|
||||
})"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> dev mode import usage check attribute expressions 1`] = `
|
||||
"import { defineComponent as _defineComponent } from 'vue'
|
||||
import { bar, baz } from './x'
|
||||
|
||||
@@ -432,6 +432,23 @@ defineExpose({ foo: 123 })
|
||||
expect(content).toMatch(`return { FooBaz, Last }`)
|
||||
assertCode(content)
|
||||
})
|
||||
|
||||
test('TS annotations', () => {
|
||||
const { content } = compile(`
|
||||
<script setup lang="ts">
|
||||
import { Foo, Bar, Baz } from './x'
|
||||
const a = 1
|
||||
function b() {}
|
||||
</script>
|
||||
<template>
|
||||
{{ a as Foo }}
|
||||
{{ b<Bar>() }}
|
||||
{{ Baz }}
|
||||
</template>
|
||||
`)
|
||||
expect(content).toMatch(`return { a, b, Baz }`)
|
||||
assertCode(content)
|
||||
})
|
||||
})
|
||||
|
||||
describe('inlineTemplate mode', () => {
|
||||
|
||||
Reference in New Issue
Block a user