jacobmischka / svelte-flatpickr

Flatpickr component for Svelte.
https://www.npmjs.com/package/svelte-flatpickr
MIT License
161 stars 22 forks source link

Small error message when using 'mode: range' in options. #40

Closed delay closed 2 years ago

delay commented 2 years ago

When adding mode: 'range' into my options for flatpickr I get this error message. It still works as expected, but it just throws this error message. Thanks for any input...

Type '{ mode: string; dateFormat: string; defaultDate: string; enableTime: boolean; onChange: (selectedDates: any, dateStr: any) => void; }' is not assignable to type 'Partial<BaseOptions>'.

const options = { mode: 'range', dateFormat: 'm/d/Y', defaultDate: '', enableTime: false, onChange: function (selectedDates, dateStr) { onDone(selectedDates[0], selectedDates[1], dateStr); }

jacobmischka commented 2 years ago

Interesting, it seems TypeScript isn't inferring that mode is a constant.

This might work:

mode: 'range' as const,
delay commented 2 years ago

Thanks so much for your help! That solved the issue.