Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ionic 2: Module 'moment' has no exported member 'UnitOfTime'. #112

Closed
mauricionarcizo opened this issue Nov 10, 2016 · 7 comments
Closed

Comments

@mauricionarcizo
Copy link

I updated the ionic-app-scripts to 0.0.42 and on process 'transpile', I got the following error:

[14:21:19] transpile started ...
[14:21:23] typescript: ...nfo/app/node_modules/angular2-moment/difference.pipe.d.ts, line: 4
Module 'moment' has no exported member 'UnitOfTime'.

   L3:  export declare class DifferencePipe implements PipeTransform {
   L4:   | moment.Moment, otherValue: Date | moment.Moment, unit?: moment.UnitOfTime, precision?: boolean): number;

[14:21:23] transpile failed

As we can see, the 'UnitOfTime' is not an exported module from 'moment'. What I can do to solve this?

Angular2-moment version used is 1.0.0-beta.6.

@JasonGoemaat
Copy link

Same issue here. I don't see anywhere in the momentjs documentation where 'UnitOfTime' exists.

@jamarisi
Copy link

jamarisi commented Nov 10, 2016

As a workaround until it gets fixed, I added class UnitOfTime {} inside of declare namespace moment {} in the file moment.d.ts, in the moment folder. With this, the project at least compiles.

But I think that this has more to do with momentjs than with this module.

@urish
Copy link
Owner

urish commented Nov 10, 2016

I confirm that angular2-moment currently produces this error with moment 2.16.0. This is the specific commit that introduced that change: moment/moment@8c0c6a3

I hope to publish a new release that will address it within the next few days. In the meanwhile, you can stick with moment 2.15.2

@mauricionarcizo
Copy link
Author

Work!
@urish thanks!

@urish urish closed this as completed in 432da35 Nov 11, 2016
@bitterloa
Copy link

Just wanted to let others know what solution worked for me--I did not revert to the older version of moment -- I am using 2.17.1. Also I didn't need to change any typings files at all.

What I did, in my angular component .ts file was to cast my string variable into the moment

some.component.ts

let convertedChartPeriod: moment.unitOfTime.StartOf = <moment.unitOfTime.StartOf>this.chartPeriod;

var reportStartDate = moment(itemDate).startOf(convertedChartPeriod);

Things of Note:

  • proper class name for v2.17.1 is moment.unitOfTime.StartOf
  • use the <moment.unitOfTime.StartOf> with the "<>" brackets to cast the string into the proper class.
  • No need to change any Damn typings files!

@jchavarria1983
Copy link

jchavarria1983 commented Aug 17, 2017

Hi everybody I have this issue: 'moment' has no exported member 'DurationInputArg1'.
Someone knows what happen ? @bitterloa @urish

Complete error:
ERROR in C:/wamp64/www/ng2-admin/node_modules/ap-angular2-fullcalendar/node_modules/@types/fullcalendar/index.d.ts (154,27): Namespace 'moment' has no exported member 'DurationInputArg1'.

Fixed but now I have another error:

ERROR TypeError: specialTokens[fakePart.substring(...)] is not a function
at renderFakeFormatStringParts (fullcalendar.js:1800)
at renderFakeFormatString (

@carcinocron
Copy link

This is still happening for me.

ERROR in /home/ubuntu/app/node_modules/angular2-moment/subtract.pipe.d.ts
(4,42): error TS2694: Namespace 'moment' has no exported member 'DurationInputArg1'.

ERROR in /home/ubuntu/app/node_modules/angular2-moment/subtract.pipe.d.ts
(4,75): error TS2694: Namespace 'moment' has no exported member 'DurationInputArg2'.

ERROR in /home/ubuntu/app/node_modules/angular2-moment/difference.pipe.d.ts
(4,92): error TS2694: Namespace 'moment' has no exported member 'unitOfTime'.

ERROR in /home/ubuntu/app/node_modules/angular2-moment/add.pipe.d.ts
(4,42): error TS2694: Namespace 'moment' has no exported member 'DurationInputArg1'.

ERROR in /home/ubuntu/app/node_modules/angular2-moment/add.pipe.d.ts
(4,75): error TS2694: Namespace 'moment' has no exported member 'DurationInputArg2'.

angular2-moment@1.7
moment@2.19.2

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants