time-ago-pipe icon indicating copy to clipboard operation
time-ago-pipe copied to clipboard

added type support for passing date as a number

Open eranation opened this issue 5 years ago • 0 comments

This fix is needed for IDEs to not complain about type mismatch, e.g. in cases such as

{{ item.modifiedDate | timeAgo }}

in case modified date is a number.

It works in practice because Date has a constructor that accepts number (milliseconds time stamp), but some IDEAs will complain about the pipe accepting only strings where the attribute is a number.

note: the ? condition seems redundant, but needed for typescript type guard to work. otherwise (at least in TS 2.7.2) it doesn't know to pick the right Date constructor based on the type of value

eranation avatar Apr 03 '19 18:04 eranation