fingerpich / jalali-moment

Display, parse, manipulate, validate and convert jalali (Persian, Khorshidi, Shamsi) or Gregorian (Miladi) dates and times.
https://fingerpich.github.io/jalali-moment/
MIT License
434 stars 68 forks source link

problem with jest #50

Closed rzkhosroshahi closed 5 years ago

rzkhosroshahi commented 5 years ago

Describe the bug Hi, khaste nabashi :) I faced an issue when I run my tests. the error is: TypeError: jalali_moment_1.default is not a function. this error solved when I use jalali-moment in typescript usage as you said in docs. but in this situation, I got another error in rollup that said can't call moment namespace :( in simple usage I haven't any error and issue except this error in the test env. you can see my project here.

Desktop (please complete the following information):

fingerpich commented 5 years ago

Hi, thanks :), sorry for delay I found some solutions in the following link https://github.com/jvandemo/generator-angular2-library/issues/221

import * as moment_ from 'moment';
const moment = moment_;

good luck

RezaNazem commented 4 years ago

hi i have same problem too, i use jalali-moment in angular library . but when i want build my library , i get
can't call moment namespace i import *import as moment from 'jalali-moment';* in my component . i read your tips . but I can't understand exactly what you mean . Do I need to delete my import `import as moment from 'jalali-moment'; and add instead of import * as moment from 'moment'; const moment = moment;` ? or add just your tips in my component ?

fingerpich commented 4 years ago

please follow the link and do the same for 'jalali-moment', because jalali-moment is a kind of plugin for moment.js.

RezaNazem commented 4 years ago

thank you . my problem is solved. i replaced import * as moment_ from 'jalali-moment'; with import * as moment_ from 'jalali-moment'; const moment = moment_;