iamkun/dayjs






The issue has been closed
`dayjs.tz()` needs to have timezone parameter as optional #1079
Miikis posted onGitHub
Describe the bug
Because you can set a default timezone, the dayjs.tz()
method should have the second parameter (timezone) as optional. It works fine in JS — just missing the correct types for TS.
Expected behavior
- Set
dayjs.tz.setDefault("America/Phoenix");
dayjs.tz('some valid date')
<- that shouldn't throw a TypeScript errordayjs('some valid date').tz()
<- that shouldn't throw a TypeScript error either
Potential Solution
declare module 'dayjs' {
interface Dayjs {
tz(timezone?: string): Dayjs;
}
interface DayjsTimezone {
(date?: ConfigType, timezone?: string): Dayjs;
}
}
Information
- Day.js Version: v1.8.36
- OS: macOS v10.15.6
- Browser: Firefox Developer Edition v82.0b2
- Time zone: America/Phoenix