fix(compiler-sfc): fix defineProps() call on imported identifier
This commit is contained in:
parent
be2b1d3c2f
commit
691d354af9
@ -73,6 +73,23 @@ return { }
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> defineProps w/ external definition 1`] = `
|
||||
"import { propsModel } from './props'
|
||||
|
||||
export default {
|
||||
props: propsModel,
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
const props = __props
|
||||
|
||||
|
||||
return { props, propsModel }
|
||||
}
|
||||
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> defineProps() 1`] = `
|
||||
"export default {
|
||||
props: {
|
||||
|
@ -48,6 +48,19 @@ const bar = 1
|
||||
},`)
|
||||
})
|
||||
|
||||
test('defineProps w/ external definition', () => {
|
||||
const { content } = compile(`
|
||||
<script setup>
|
||||
import { defineProps } from 'vue'
|
||||
import { propsModel } from './props'
|
||||
const props = defineProps(propsModel)
|
||||
</script>
|
||||
`)
|
||||
assertCode(content)
|
||||
expect(content).toMatch(`export default {
|
||||
props: propsModel,`)
|
||||
})
|
||||
|
||||
test('defineEmit() (deprecated)', () => {
|
||||
const { content, bindings } = compile(`
|
||||
<script setup>
|
||||
|
@ -1492,7 +1492,15 @@ export function walkIdentifiers(
|
||||
})
|
||||
}
|
||||
|
||||
function isRefIdentifier(id: Identifier, parent: Node, parentStack: Node[]) {
|
||||
function isRefIdentifier(
|
||||
id: Identifier,
|
||||
parent: Node | null,
|
||||
parentStack: Node[]
|
||||
) {
|
||||
if (!parent) {
|
||||
return true
|
||||
}
|
||||
|
||||
// declaration id
|
||||
if (
|
||||
(parent.type === 'VariableDeclarator' ||
|
||||
|
Loading…
Reference in New Issue
Block a user