You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a bunch of places in my HTML templates that use the amTimeAgo pipe like this:
{{myObj.someDateProp | amTimeAgo}}
Where someDateProp is an ISO8601 date string. This has been working without any issues so far.
However, when I try to enable the fullTemplateTypeCheck Angular compiler option, I get an error saying "Argument of type 'string' is not assignable to parameter of type 'Date | Moment'."
It looks like this is because the transform method of TimeAgoPipe specifies a type of Date or Moment, even though the underlying code supports strings and numbers too.
Using Rollup/Webpack/System.js/Ionic/similar? Webpack
The text was updated successfully, but these errors were encountered:
theodorejb
changed the title
Support passing string to amTimeAgo pipe when fullTemplateTypeCheck is enabled
TimeAgoPipe doesn't support string dates when fullTemplateTypeCheck is enabled
Nov 15, 2018
There are a bunch of places in my HTML templates that use the
amTimeAgo
pipe like this:Where
someDateProp
is an ISO8601 date string. This has been working without any issues so far.However, when I try to enable the
fullTemplateTypeCheck
Angular compiler option, I get an error saying "Argument of type 'string' is not assignable to parameter of type 'Date | Moment'."It looks like this is because the
transform
method ofTimeAgoPipe
specifies a type of Date or Moment, even though the underlying code supports strings and numbers too.ngx-moment/src/time-ago.pipe.ts
Line 21 in 834d75f
This can be fixed by changing the relevant type signatures in
TimeAgoPipe
tomoment.MomentInput
instead ofDate | moment.Moment
.Note: according to the Angular docs the
fullTemplateTypeCheck
option "will default to true in the future" (see https://angular.io/guide/aot-compiler#fulltemplatetypecheck).Did you search for duplicate issue? Yes
Environment:
moment
version? 2.22.2moment-timezone
? NoThe text was updated successfully, but these errors were encountered: