mirror of https://github.com/vuejs/core.git
fix(compiler-sfc): fix regression on props destructure when transform is not enabled
close #8289
This commit is contained in:
parent
80a708f17a
commit
f25bd37c67
|
@ -38,6 +38,26 @@ return { props }
|
|||
})"
|
||||
`;
|
||||
|
||||
exports[`defineProps > destructure without enabling reactive destructure 1`] = `
|
||||
"import { defineComponent as _defineComponent } from 'vue'
|
||||
|
||||
export default /*#__PURE__*/_defineComponent({
|
||||
props: {
|
||||
foo: { type: null, required: true }
|
||||
},
|
||||
setup(__props: any, { expose: __expose }) {
|
||||
__expose();
|
||||
|
||||
const { foo } = __props;
|
||||
|
||||
|
||||
|
||||
return { }
|
||||
}
|
||||
|
||||
})"
|
||||
`;
|
||||
|
||||
exports[`defineProps > w/ TS assertion 1`] = `
|
||||
"import { defineComponent as _defineComponent } from 'vue'
|
||||
|
||||
|
|
|
@ -586,6 +586,19 @@ const props = defineProps({ foo: String })
|
|||
})
|
||||
})
|
||||
|
||||
// #8289
|
||||
test('destructure without enabling reactive destructure', () => {
|
||||
const { content } = compile(
|
||||
`<script setup lang="ts">
|
||||
const { foo } = defineProps<{
|
||||
foo: Foo
|
||||
}>()
|
||||
</script>`
|
||||
)
|
||||
expect(content).toMatch(`const { foo } = __props`)
|
||||
assertCode(content)
|
||||
})
|
||||
|
||||
describe('errors', () => {
|
||||
test('w/ both type and non-type args', () => {
|
||||
expect(() => {
|
||||
|
|
|
@ -28,6 +28,7 @@ export function processPropsDestructure(
|
|||
declId: ObjectPattern
|
||||
) {
|
||||
if (!ctx.options.propsDestructure && !ctx.options.reactivityTransform) {
|
||||
ctx.propsIdentifier = ctx.getString(declId)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue