svelte-calendar icon indicating copy to clipboard operation
svelte-calendar copied to clipboard

Warning when using with TypeScript

Open nstuyvesant opened this issue 4 years ago • 4 comments

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?

nstuyvesant avatar May 29 '21 19:05 nstuyvesant

https://github.com/IBM/sveld

A coworker recommended this approach.

6eDesign avatar Jun 02 '21 04:06 6eDesign

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> {}
}

nstuyvesant avatar Aug 16 '21 01:08 nstuyvesant

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.

6eDesign avatar Sep 19 '21 18:09 6eDesign

oops - didn't mean to close.

6eDesign avatar Sep 19 '21 18:09 6eDesign