fix: withDefaults case
This commit is contained in:
parent
844ec6db3b
commit
683131040b
|
|
@ -52,7 +52,7 @@
|
|||
"chalk": "5.3.0",
|
||||
"commander": "^11.0.0",
|
||||
"cosmiconfig": "^8.3.6",
|
||||
"detype": "npm:detypes@^0.7.0",
|
||||
"detype": "npm:detypes@^0.7.1",
|
||||
"diff": "^5.1.0",
|
||||
"execa": "^8.0.1",
|
||||
"fs-extra": "^11.1.1",
|
||||
|
|
|
|||
|
|
@ -22,8 +22,17 @@ const emit = defineEmits([\\"foo\\"]);
|
|||
|
||||
exports[`transformSFC > defineProps 1`] = `
|
||||
"<script setup>
|
||||
const defineProps({
|
||||
foo: { type: String, required: true }
|
||||
});
|
||||
</script>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`transformSFC > defineProps with withDefaults 1`] = `
|
||||
"<script setup>
|
||||
const props = defineProps({
|
||||
foo: { type: String, required: true },
|
||||
foo: { type: String, required: true, default: \\"bar\\" },
|
||||
});
|
||||
</script>
|
||||
"
|
||||
|
|
|
|||
|
|
@ -35,6 +35,20 @@ describe('transformSFC', () => {
|
|||
expect(result).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('defineProps with withDefaults', async () => {
|
||||
const result = await transform({
|
||||
filename: 'app.vue',
|
||||
raw: `<script lang="ts" setup>
|
||||
const props = withDefaults(defineProps<{ foo: string }>(), {
|
||||
foo: 'bar'
|
||||
})
|
||||
</script>
|
||||
`,
|
||||
config: {},
|
||||
})
|
||||
expect(result).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('defineEmits', async () => {
|
||||
const result = await transform({
|
||||
filename: 'app.vue',
|
||||
|
|
|
|||
|
|
@ -188,8 +188,8 @@ importers:
|
|||
specifier: ^8.3.6
|
||||
version: 8.3.6(typescript@5.2.2)
|
||||
detype:
|
||||
specifier: npm:detypes@^0.7.0
|
||||
version: /detypes@0.7.0
|
||||
specifier: npm:detypes@^0.7.1
|
||||
version: /detypes@0.7.1
|
||||
diff:
|
||||
specifier: ^5.1.0
|
||||
version: 5.1.0
|
||||
|
|
@ -4049,8 +4049,8 @@ packages:
|
|||
engines: {node: '>=12.20'}
|
||||
dev: true
|
||||
|
||||
/detypes@0.7.0:
|
||||
resolution: {integrity: sha512-W2ICgnPKbXbs9XEexlHXCL4XBRUvjtBLgw5iIYPxHzUnmQfE+gXEDrGlxOLkxvKm9irP810JUDoDlKof0dwI1g==}
|
||||
/detypes@0.7.1:
|
||||
resolution: {integrity: sha512-s8qAzypZhYRc6L3l7Dfown3E3f73VVOXmU5NIZXNUVi+jiX7gKeeDcD9VlYdL64XDEcR9SZz5yo9IhmDsCwv7g==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user