Property 'fromNow' does not exist on type 'Dayjs'
See original GitHub issueI’m using the relativeTime
plugin in my .ts
file
Importing is done in below manner : -
import * as dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);
I’ve also tried to change the import statement as:
import dayjs from 'dayjs';
But started throwing new error as no exported member
Now when I’m using in the fromNow
function as: -
dayjs(this.created_at).fromNow();
the compiler is throwing an error
Property 'fromNow' does not exist on type 'Dayjs'
I’m using "dayjs": "^1.7.4",
version
What’s the with usage? How can I fix this?
@iamkun Please address this issue
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:29 (8 by maintainers)
Top Results From Across the Web
Time from now
Range Key Sample Output
0 to 44 seconds s a few seconds ago
45 to 89 seconds m a minute ago
90 seconds to 44 minutes...
Read more >Property 'dayjs' does not exist on type 'Cypress & EventEmitter ...
I've been looking at this, but I'm struggling to figure out how I add in dayJS. The instructions are entirely focused on adding...
Read more >The Complete Guide to Day.js - Mirza Leka - Medium
To run Day.js, simply type dayjs() and this will generate you a ... If you are importing a locale that doesn't exist you'll...
Read more >Property 'tz' does not exist on type 'Dayjs' #1128 - Issuehunt
Describe the bug When trying to set timezone on dayjs TS throws the following error: Property 'tz' does not exist on type 'Dayjs'...
Read more >dayjs - npm
dayjs. TypeScript icon, indicating that this package has built-in type declarations · Readme · Code Beta · 0 Dependencies · 9,659 Dependents ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This worked fine for me, in case anyone still needs it
You need at least one import statement to use Module Augmentation.
Also it seems you can nest module augmentation in
declare module
.