DaniSchenk / moment-feiertage

MomentJS Plugin: Check if a date is a german holiday (Feiertag)
https://www.npmjs.com/package/moment-feiertage
30 stars 11 forks source link

Add typescript definition #10

Closed Schlumpf9 closed 4 years ago

Schlumpf9 commented 4 years ago

Hey, it would be great if the project contains a typescript index.d.ts file. So in typescript projects as in Angular the compiler doesn't claim that the function isHoliday doesn't exist.

DaniSchenk commented 4 years ago

hey @Schlumpf9, I will come up with a solution in a few days and will let you know when there's a new release.

DaniSchenk commented 4 years ago

hey @Schlumpf9 , I'm trying to rewrite the plugin with TypeScript. Unfortunately I'm still trying... 😥 It would be great if anyone could help solving my issue https://github.com/moment/moment/issues/5341#issue-546064276 in the official moment repo

Schlumpf9 commented 4 years ago

I was able to compile my Angular project with the following definitions:

types/moment/index.d.ts

import moment = require('moment');
export = moment;

declare module 'moment' {
    interface MomentHolidayResult {
        allStates: boolean,
        holidayName: string,
        holidayStates: Array<string>,
        testedStates: Array<string>
    }

    interface Moment {
        isHoliday(_states?: string | Array<string>): MomentHolidayResult;
    }
}
DaniSchenk commented 4 years ago

@Schlumpf9 I finished the refactoring and published a new version. Feel free to give feedback 🙂