fix(compiler-sfc): fix props codegen w/ leading import

fix #4764
This commit is contained in:
Evan You
2021-10-08 12:52:48 -04:00
parent 9e3d7731c7
commit d4c04e9799
4 changed files with 51 additions and 14 deletions

View File

@@ -58,7 +58,7 @@ exports[`SFC compile <script setup> <script> and <script setup> co-usage spaces
"import { x } from './x'
export const n = 1
const __default__ = {
const __default__ = {
some:'option'
}
@@ -79,7 +79,7 @@ exports[`SFC compile <script setup> <script> and <script setup> co-usage spaces
"import { x } from './x'
export const n = 1
const __default__ = {
const __default__ = {
some:'option'
}
@@ -392,6 +392,7 @@ export default {
expose()
const props = __props
return { props, propsModel }
@@ -400,6 +401,23 @@ return { props, propsModel }
}"
`;
exports[`SFC compile <script setup> defineProps w/ leading code 1`] = `
"import { x } from './x'
export default {
props: {},
setup(__props, { expose }) {
expose()
const props = __props
return { props, x }
}
}"
`;
exports[`SFC compile <script setup> defineProps() 1`] = `
"export default {
props: {
@@ -410,6 +428,7 @@ exports[`SFC compile <script setup> defineProps() 1`] = `
const props = __props
const bar = 1
return { props, bar }
@@ -426,6 +445,7 @@ exports[`SFC compile <script setup> defineProps/defineEmits in multi-variable de
expose()
const props = __props
return { props, emit }
@@ -442,6 +462,7 @@ exports[`SFC compile <script setup> defineProps/defineEmits in multi-variable de
expose()
const props = __props
const a = 1;
return { props, a, emit }
@@ -814,7 +835,7 @@ return (_ctx, _cache) => {
}),
_createElementVNode(\\"div\\", {
onClick: _cache[5] || (_cache[5] = () => {
let a = '' + _unref(lett)
let a = '' + _unref(lett)
_isRef(v) ? v.value = a : v = a
})
}),
@@ -828,7 +849,7 @@ return (_ctx, _cache) => {
let z2 = z
})
let lz = _ctx.z
})
})
_isRef(v) ? v.value = _ctx.a : v = _ctx.a
})
})
@@ -1286,6 +1307,7 @@ const props = __props
return { props, emit }
}
@@ -1360,6 +1382,7 @@ const props = __props as {
bar?: number
baz: boolean
}
return { props, defaults }
@@ -1382,6 +1405,7 @@ export default /*#__PURE__*/_defineComponent({
expose()
const props = __props as { foo: string, bar?: number, baz: boolean, qux(): number }
return { props }

View File

@@ -119,6 +119,7 @@ export default {
setup(__props) {
const rest = _createPropsRestProxy(__props, [\\"foo\\",\\"bar\\"])
return () => {}