fix(compiler-sfc): add type for props's properties in prod mode (#4790)

fix #4783
This commit is contained in:
ygj6
2021-11-03 10:04:04 +08:00
committed by GitHub
parent d56f115f71
commit 090df0837e
3 changed files with 22 additions and 13 deletions

View File

@@ -82,7 +82,9 @@ export default /*#__PURE__*/_defineComponent({
props: {
foo: { default: 1 },
bar: { default: () => {} },
baz: null
baz: null,
boola: { type: Boolean },
boolb: { type: [Boolean, Number] }
},
setup(__props: any) {

View File

@@ -83,7 +83,7 @@ describe('sfc props transform', () => {
const { content } = compile(
`
<script setup lang="ts">
const { foo = 1, bar = {} } = defineProps<{ foo?: number, bar?: object, baz?: any }>()
const { foo = 1, bar = {} } = defineProps<{ foo?: number, bar?: object, baz?: any, boola?: boolean, boolb?: boolean | number }>()
</script>
`,
{ isProd: true }
@@ -93,7 +93,9 @@ describe('sfc props transform', () => {
expect(content).toMatch(`props: {
foo: { default: 1 },
bar: { default: () => {} },
baz: null
baz: null,
boola: { type: Boolean },
boolb: { type: [Boolean, Number] }
}`)
assertCode(content)
})