You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: many issues are resolved if you just upgrade to the latest version
Issue description:
The function returns undefined, it's not conform to the interface in index.d.js.
I think it should change themoment.Moment to moment.Moment | undefined
or throw an error like we pass a timezone which is not exist?
interface Moment {
tz(): string | undefined;
tz(timezone: string, keepLocalTime?: boolean): moment.Moment; // or should be moment.Moment | undefined ?
zoneAbbr(): string;
zoneName(): string;
}
The text was updated successfully, but these errors were encountered:
First up, please don't list "latest" in the version field, as it becomes incorrect very quickly. For example, a new version has already been published today. To diagnose issues, we need exact version numbers.
From looking at the code, it seems moment().tz('') is treated exactly the same as moment().tz(), returning string | undefined. This is because of a check of if (zone) which treats the empty string the same as undefined.
I agree that this behaviour doesn't match the type definitions, and isn't quite correct. But fixing it would technically be a breaking change, as code that worked previously could start throwing errors. I'm going to link this to the proposed breaking changes in #1039.
Moment-timezone version which you use:
Version: latest
Note: many issues are resolved if you just upgrade to the latest version
Issue description:
The function returns undefined, it's not conform to the interface in index.d.js.
I think it should change the
moment.Moment
tomoment.Moment | undefined
or throw an error like we pass a timezone which is not exist?
The text was updated successfully, but these errors were encountered: