svelte-calendar
svelte-calendar copied to clipboard
Warning when using with TypeScript
Getting...
Cannot find module 'svelte-calendar' or its corresponding type declarations when importing it
import Datepicker from 'svelte-calendar'
Didn't see an @types/svelte-calendar out there either. Any chance of some type definitions in the future?
https://github.com/IBM/sveld
A coworker recommended this approach.
Allain Chain suggested:
import Datepicker from 'svelte-calendar/src/Components/Datepicker.svelte'
as a workaround. This worked for me though I would like to have proper types for the Datepicker.
This is what I started...
declare module 'svelte-calendar' {
interface DatepickerProps
extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap['div']> {
format?: string
start?: Date
end?: Date
selected?: Date
dateChosen?: boolean
trigger?: () => void
selectableCallback?: () => void
weekStart?: number
daysOfWeek?: Array<string, string>
monthsOfYear?: Array<string, string>
style?: string
buttonBackgroundColor?: string
buttonBorderColor?: string
buttonTextColor?: string
highlightColor?: string
dayBackgroundColor?: string
dayTextColor?: string
dayHighlightedBackgroundColor?: string
dayHighlightedTextColor?: string
}
export class Datepicker extends SvelteComponentTyped<DatepickerProps> {}
}
I have rewritten this component using svelte kit and used svelte-kit package to publish the package along with various type files. I am not personally using typescript in my projects. Please try out the new v3 version of this component library and let me know if this issue can be closed.
oops - didn't mean to close.