【发布时间】:2020-01-24 16:36:21
【问题描述】:
These are the commonly accepted ways of doing it in Javascript.
然而使用 Typescript 是我们做!isNaN(someDate),typescript 抱怨我们使用的方法接受数字,而不是日期。
关于如何处理这个问题的想法?
【问题讨论】:
-
既然你是专门做类型检查的,那
isNaN(somedate as any)呢? -
明白了。 Javascript 是个挑剔的混蛋 :)
-
只需使用
!isNaN(someDate.valueOf())... 或getTime()作为the accepted answer on the question you linked to shows... -
很好
as any和valueOf()工作!谢谢!!
标签: javascript node.js typescript date types