Moment-timezone: Property 'tz' does not exist on type 'Moment' Error

Created on 5 Nov 2020  路  3Comments  路  Source: moment/moment-timezone

nodejs version: 12.18.4
moment-timezone version:0.5.31
moment version: ^2.29.0
ts-node version: happens both in 9.0.0(latest), 8.6.2
command: ts-node --files server/app.ts --project server/tsconfig.build.json

usage

import moment from 'moment-timezone'
moment(somedate).tz(sometimezone)

No @types/moment or @types/moment-timezone installed since deprecated.

What could be the reason ?

PS: Already checked this Issue

bug

Most helpful comment

I resolved this by downgrading the moment-timezone package to 0.5.28 (instead of 0.5.31).

I found that the offending lines in 0.5.31 with my setup are:

index.d.ts:

zonesForCountry<T extends true>(country: string, with_offset: T): T extends true ? MomentZoneOffset[] : never;
zonesForCountry<T extends false>(country: string, with_offset?: T): T extends false ? string[] : never;

All 3 comments

I'm having exactly the same issue.

node version: 12.14.1
moment version: 2.24.0
moment-timezone version: 0.5.31
ts-node version: 8.3.0

Usages:

import * as moment from 'moment';
import 'moment-timezone';
moment.tz.setDefault('UTC');
import * as moment from 'moment-timezone';
moment.tz.setDefault('UTC');



md5-3af2c6f3090bd525163b2fc71b7688ef



TS2339: Property 'tz' does not exist on type 'typeof moment'.

Any update regarding this ?

I resolved this by downgrading the moment-timezone package to 0.5.28 (instead of 0.5.31).

I found that the offending lines in 0.5.31 with my setup are:

index.d.ts:

zonesForCountry<T extends true>(country: string, with_offset: T): T extends true ? MomentZoneOffset[] : never;
zonesForCountry<T extends false>(country: string, with_offset?: T): T extends false ? string[] : never;
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dharapvj picture dharapvj  路  4Comments

grokcode picture grokcode  路  6Comments

guidsen picture guidsen  路  4Comments

ghost picture ghost  路  4Comments

im1dermike picture im1dermike  路  4Comments