Closed otatar closed 1 year ago
I was just about to post the same issue 👍
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:
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:
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?
@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
}
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: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 toes2020
, but that's causing even more issues: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
The same issue here :/
Cannot be used with typescript: