Vuepic / vue-datepicker

Datepicker component for Vue 3
https://vue3datepicker.com
MIT License
1.4k stars 137 forks source link

Error when trying to wrap `VueDatePicker` component with it's own props type `VueDatePickerProps` #858

Closed MellKam closed 2 months ago

MellKam commented 2 months ago

In my project I created the wrapper component for datepicker with custom styles and exposed the original props by using VueDatePickerProps type. But after the update from 8.4.0 to 8.5.1 i got this error Pre-transform error: Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got AssignmentPattern.. Here is the simplified version of my component

<script setup lang="ts">
import Datepicker, {
    VueDatePickerProps,
    EmitEvents,
} from "@vuepic/vue-datepicker";
import "@vuepic/vue-datepicker/dist/main.css";
import { useEmitAsProps } from "radix-vue";

const props = withDefaults(defineProps<VueDatePickerProps>(), {
    config: () => ({ closeOnAutoApply: true }),
    autoApply: true,
    dark: true,
});

const emit = defineEmits<{
    [K in EmitEvents]: [...args: any[]];
}>();

const emitsAsProps = useEmitAsProps(emit);
</script>

<template>
    <Datepicker v-bind="{ ...props, ...emitsAsProps }" />
</template>

<style>
// custom styles...
</style>

Reproduction: https://stackblitz.com/edit/vuepic-vue-datepicker-2fraph?file=src%2Fcomponents%2FPlayground.vue

peter-emad99 commented 2 months ago

i have the same error aslo

Jasenkoo commented 2 months ago

The suspected root cause is the same as on #854

Jasenkoo commented 2 months ago

Confirmed, fixed in 441a8c67cfb9256db2da2b574e0560db5a59d8a1