New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate isValid function to TS #2308
Conversation
src/isValid/index.ts
Outdated
requiredArgs(1, arguments) | ||
|
||
var date = toDate(dirtyDate) | ||
return !isNaN(date) | ||
if (!(dirtyDate instanceof Date) && typeof dirtyDate !== 'number') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to use isDate
here since it handles an iframe passing edge case not covered by instanceof alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 👍
@tan75 I think that last change was a mistake. The predicate With predicate, we narrow the result down to Date or number: |
As I pointed out here #2551 (comment), the remaining problem is with the jsdocs / type generator system for these type guards in How to write the jsdocs part: microsoft/TypeScript#25127 (comment) |
Co-authored-by: Tetiana <ttobin@protonmail.ch> Co-authored-by: Sasha Koss <koss@nocorp.me>
This pr fixes date-fns/date-fns-typescriptify#101