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
Looking at the source, there is a definition for a class named Dayjs with a constructor. Even in the type definition files I can see this class in the namespace dayjs.
And in line 48 of 'dayjs/esm/index.js' return new Dayjs(cfg); is used.
But when I try to use const demo = new dayjs.Dayjs() or const demo = new dayjs() all I get when running the program is an error that says TypeError: dayjs.Dayjs is not a constructor no matter if I use
node.js with commonjs (const dayjs = require('dayjs'); or
node.js with esm (import dayjs from 'dayjs';'); or
typescript (angular 11) with esm (import dayjs from 'dayjs/esm';');
So the question is: what am I doing wrong; where is my misinterpretation of the source / type definition.
Information
Day.js Version [e.g. v1.10.5]
OS: windows 10
node 14.17.1
The text was updated successfully, but these errors were encountered:
IMHO it's a babel theme. The (esm) source clearly has a class with a constructor. But it seams that node will not recognize the code generated by babel as a class.
So for the esm version in dayjs/esm I am asking myself, why do you let babel transform esm to esm? But probably I just don't get the point :-)
New React project made via create-react-app (which uses webpack), with antd as the UI library. Their datepicker uses dayjs for some reason, and it is not working because of this exact problem - "dayjs is not a constructor"
Specifically:
dayjs__WEBPACK_IMPORTED_MODULE_14___default(...).Dayjs is not a constructor
TypeError: dayjs__WEBPACK_IMPORTED_MODULE_14___default(...).Dayjs is not a constructor
at DrawRouteDetails (http://localhost:3000/static/js/bundle.js:6912:40)
at renderWithHooks (http://localhost:3000/static/js/bundle.js:151075:22)
at updateFunctionComponent (http://localhost:3000/static/js/bundle.js:153955:24)
at beginWork (http://localhost:3000/static/js/bundle.js:155667:20)
at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:140671:18)
at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:140715:20)
at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:140772:35)
at beginWork$1 (http://localhost:3000/static/js/bundle.js:160636:11)
at performUnitOfWork (http://localhost:3000/static/js/bundle.js:159884:16)
at workLoopSync (http://localhost:3000/static/js/bundle.js:159807:9)
Looking at the source, there is a definition for a class named
Dayjs
with a constructor. Even in the type definition files I can see this class in the namespace dayjs.And in line 48 of 'dayjs/esm/index.js'
return new Dayjs(cfg);
is used.But when I try to use
const demo = new dayjs.Dayjs()
orconst demo = new dayjs()
all I get when running the program is an error that saysTypeError: dayjs.Dayjs is not a constructor
no matter if I useconst dayjs = require('dayjs');
orimport dayjs from 'dayjs';');
orimport dayjs from 'dayjs/esm';');
So the question is: what am I doing wrong; where is my misinterpretation of the source / type definition.
Information
The text was updated successfully, but these errors were encountered: