diff --git a/types/node-cron/index.d.ts b/types/node-cron/index.d.ts index 6cd1b1445e..6c4018a447 100644 --- a/types/node-cron/index.d.ts +++ b/types/node-cron/index.d.ts @@ -1,9 +1,12 @@ // Type definitions for node-cron 2.0 // Project: https://github.com/node-cron/node-cron, https://github.com/merencia/node-cron // Definitions by: morsic , -// burtek +// burtek , +// Richard Honor // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import { Timezone } from 'tz-offset'; + export function schedule(cronExpression: string, func: () => void, options?: ScheduleOptions): ScheduledTask; export function validate(cronExpression: string): boolean; @@ -24,5 +27,5 @@ export interface ScheduleOptions { /** * The timezone that is used for job scheduling */ - timezone?: string; + timezone?: Timezone; } diff --git a/types/node-cron/node-cron-tests.ts b/types/node-cron/node-cron-tests.ts index 17350b6427..f987d41334 100644 --- a/types/node-cron/node-cron-tests.ts +++ b/types/node-cron/node-cron-tests.ts @@ -45,3 +45,10 @@ const invalid = cron.validate('60 * * * *'); if (valid && !invalid) { log('validator works'); } + +// check timezones are accepted from the string literal +const tast4 = cron.schedule('* * * * *', () => { + log('will execute every minute until stopped'); +}, { timezone: 'Europe/London' }); + +tast4.destroy();