Search code examples
typescriptdayjs

How to use dayjs in typescript


import * as dayjs from 'dayjs'
  • debug success
  • build Cannot call a namespace ('dayjs'), TypeError: dayjs__namespace is not a function

try another

const dayjs = require('dayjs')
  • build success
  • debug ReferenceError: require is not defined

How can I do?


Solution

  • I am using dayjs in my typescript project like below

    import dayjs from 'dayjs';
    :
    this.date = params.get('date') ? dayjs().format('DD/MM/YYYY') : '';