Dayjs class undefined at runtime
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Importing the `Dayjs` class results in `undefined` at runtime. Command clicking into the `Dayjs` symbol brings me to the correct definition in `index.d.ts` as expected. This happens when using `require` and ESM.
```ts
import dayjs from "dayjs";
// OR
const dayjs = require("dayjs");
console.log("dayjs.Dayjs:", dayjs.DayJs);
console.log("dayjs:", dayjs);
```
Output:
```txt
dayjs.Dayjs: undefined
dayjs: [Function: O] {
extend: [Function (anonymous)],
locale: [Function: t],
isDayjs: [Function: S],
unix: [Function (anonymous)],
en: {
name: 'en',
weekdays: [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
],
months: [
'January', 'February',
'March', 'April',
'May', 'June',
'July', 'August',
'September', 'October',
'November', 'December'
],
ordinal: [Function: ordinal]
},
Ls: {
en: {
name: 'en',
weekdays: [Array],
months: [Array],
ordinal: [Function: ordinal]
}
},
p: {}
}
```
Command clicking `Dayjs` in vscode brings us to the correct `index.d.ts` definition:
**Expected behavior**
The `Dayjs` class should
**Information**
- Day.js Version 1.11.13
- OS: macOS
- Browser: Node.js v22
- Time zone: GMT-07:00 DST (Pacific Daylight Time)
Contributor guide
Research direction
Start by comparing the runtime exports from the package with the Dayjs declaration in index.d.ts under Node.js, using both the import and require forms described in the report. Done means the documented Dayjs class is available at runtime in the reported usage modes and the existing behavior is covered by a reproducible check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, typescript
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100