commenthol / date-holidays

worldwide holidays
https://commenthol.github.io/date-holidays/
Other
911 stars 236 forks source link

[3.16.5][Typescript] 1:20 error HolidaysTypes not found in 'date-holidays' import/named #354

Closed MartinX3 closed 1 year ago

MartinX3 commented 2 years ago

It happens now and worked before.

eslint --ext ".js,.ts,.vue" --ignore-path .gitignore --fix .

1:20  error  HolidaysTypes not found in 'date-holidays'  import/named

✖ 1 problem (1 error, 0 warnings)

Process finished with exit code 1

IntelliJ tells me ESLint: HolidaysTypes not found in 'date-holidays'(import/named)

My code

import Holidays, { HolidaysTypes } from 'date-holidays'
import EventBuilder from '~/models/builder/events/calendar/EventBuilder'
import EEvent from '~/models/enums/EEvent'

export default function useCalendar() {
    const holidays = new Holidays('DE', { languages: ['de'] })

    return {
        getHolidays: (year: number) =>
            holidays.getHolidays(year).map((it: HolidaysTypes.Holiday) => new EventBuilder().allDay(true).category(EEvent.Feiertag).date(it.start, it.end).name(it.name).build()),
    }
}
commenthol commented 1 year ago

HI @MartinX3, I am sorry but I can't help here. The type definitions have not been touched for some while. So please try to be more specific and try to reproduce which version works and since when it is broken. Please also make sure that your tsconfig matches your project changes... Feel free to reopen the issue if you have more information for us.

MartinX3 commented 1 year ago

I fixed it by using import Holidays, * as DateHolidays from 'date-holidays' it: DateHolidays.HolidaysTypes.Holiday

Maybe caused by https://github.com/import-js/eslint-plugin-import/issues/1883 or https://github.com/import-js/eslint-plugin-import/issues/1845 while using up to date packages.