Skip to content

Cannot be used with typescript #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
otatar opened this issue Jul 5, 2023 · 5 comments · Fixed by #28
Closed

Cannot be used with typescript #19

otatar opened this issue Jul 5, 2023 · 5 comments · Fixed by #28
Assignees

Comments

@otatar
Copy link

otatar commented Jul 5, 2023

Cannot be used with typescript:

Could not find a declaration file for module 'tailwind-datepicker-react'
@mihaisevencode
Copy link

I was just about to post the same issue 👍

@mihaisevencode
Copy link

So... I pulled the repo to take a look at it myself, and the reason why there's no declaration file generated is that the build:dts script fails with the following:
image
Now, I've checked the TypeScript repo and as per this issue, it looks like this type is only available in es2020. I've played around with changing the target to es2020, but that's causing even more issues:
image
The only easy way of fixing this I've found is just ts-ignoreing that line, which does emit declaration files. @OMikkel What do you reckon we should do in this case?

@mihaisevencode
Copy link

@otatar For the time being, you can just create a tailwind-datepicker-react.d.ts file with the following content:

declare module 'tailwind-datepicker-react' {
  import { ReactElement } from 'react';

  interface ITheme {
    background: string;
    todayBtn: string;
    clearBtn: string;
    icons: string;
    text: string;
    disabledText: string;
    input: string;
    inputIcon: string;
    selected: string;
  }

  interface IIcons {
    prev: () => ReactElement;
    next: () => ReactElement;
  }

  export interface IOptions {
    title?: string;
    autoHide?: boolean;
    todayBtn?: boolean;
    todayBtnText?: string;
    clearBtn?: boolean;
    clearBtnText?: string;
    maxDate?: Date;
    minDate?: Date;
    theme?: ITheme;
    icons?: IIcons;
    datepickerClassNames?: string;
    defaultDate?: Date | null;
    language?: string;
    weekDays?: string[];
    disabledDates?: Date[];
    inputNameProp?: string;
    inputIdProp?: string;
    inputPlaceholderProp?: string;
    inputDateFormatProp?: Intl.DateTimeFormatOptions;
  }

  type DatepickerProps = {
    children?: ReactElement | ReactNode;
    options?: IOptions;
    onChange?: (date: Date) => void;
    show: boolean;
    setShow: (show: boolean) => void;
    classNames?: string;
    selectedDateState?: [Date, (date: Date) => void];
  }

  export default function Datepicker(props: DatepickerProps): ReactElement
}

@OMikkel
Copy link
Owner

OMikkel commented Jul 14, 2023

So... I pulled the repo to take a look at it myself, and the reason why there's no declaration file generated is that the build:dts script fails with the following:

image

Now, I've checked the TypeScript repo and as per this issue, it looks like this type is only available in es2020. I've played around with changing the target to es2020, but that's causing even more issues:

image

The only easy way of fixing this I've found is just ts-ignoreing that line, which does emit declaration files. @OMikkel What do you reckon we should do in this case?

I will be pushing a new version where the ts error is ignored.
It is not really a huge deal ignoring that error since it obviously exists on the class Intl

@OMikkel OMikkel self-assigned this Jul 14, 2023
@nadamai
Copy link

nadamai commented Jul 31, 2023

The same issue here :/

OMikkel added a commit that referenced this issue Aug 7, 2023
Fixes #19
Add ts-ignore to Intl.Locale type error
OMikkel added a commit that referenced this issue Aug 7, 2023
* Cannot be used with typescript
Fixes #19
Add ts-ignore to Intl.Locale type error

* 1.4.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants