question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property 'fromNow' does not exist on type 'Dayjs'

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:29 (8 by maintainers)

github_iconTop GitHub Comments

38reactions
break7533commented, Jul 21, 2020
import * as dayjs from 'dayjs';
import * as relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);

This worked fine for me, in case anyone still needs it

9reactions
yprestocommented, Nov 29, 2018

You need at least one import statement to use Module Augmentation.

import 'dayjs'
declare module 'dayjs' {
    interface Dayjs {
      ...

Also it seems you can nest module augmentation in declare module.

declare module 'dayjs/plugin/relativeTime' {
  module 'dayjs' {
    ...
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found