ankurk91 / vue-flatpickr-component

Vue.js component for Flatpickr datetime picker :calendar:
https://ankurk91.github.io/vue-flatpickr-component/
MIT License
964 stars 102 forks source link

Using new vue 3.4 is breaking the options typescript #288

Open MLMdlb opened 6 months ago

MLMdlb commented 6 months ago
[X] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[ ] Other, please describe

Tell about your platform

Current behavior

Code snippet :

const pickerConfig = ref<flatpickr.Options.Options>({
  ...computedConfig.value,
  enableTime: typeof props?.others !== 'boolean' ? props?.others?.$comment?.includes('Time') : false,
  time_24hr: true,
  wrap: true,
  dateFormat: 'd/m/Y', 
})

error from tsc :

error TS2322: Type '{ allowInput?: boolean | undefined; allowInvalidPreload?: boolean | undefined; altFormat?: string | undefined; altInput?: boolean | undefined; altInputClass?: string | undefined; ... 56 more ...; wrap?: boolean | undefined; }' is not assignable to type 'Partial<BaseOptions>'.

79     <flat-pickr v-model="date" :config="pickerConfig" />
                                  ~~~~~~~
vue-flatpickr-component/dist/types/component.d.ts:85:5
    85     config: Partial<import("flatpickr/dist/types/options").BaseOptions>;
           ~~~~~~
    The expected type comes from property 'config' which is declared here on type 'Partial<{ config: Partial<BaseOptions>; events: HookKey[]; disabled: boolean; }> & Omit<{ readonly disabled: boolean; readonly modelValue: DateOption | DateOption[] | null; ... 15 more ...; "onOn-pre-calendar-position"?: ((...args: any[]) => any) | undefined; } & ... 4 more ... & { ...; }, "disabled" | ... 1 more .....'

Expected behavior No bug

Minimal reproduction of the problem with instructions

<flat-pickr v-model="date" :config="pickerConfig" />

ankurk91 commented 6 months ago

Please share a minimal re-production on platforms like https://codesandbox.io/