Skip to content
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

"Type 'TZDate' is not assignable to type 'ResultDate'" when using tz with the in context property for some date-fns functions. #29

Open
kai-moseley opened this issue Nov 7, 2024 · 0 comments

Comments

@kai-moseley
Copy link

I'm not super sure whether this is best added to this project's issues or the main date-fns one!

When using the in context property with some functions, such as endOfDay, the following TS error is shown:

endOfDay(date, { in: options.in ?? tz('UTC')})

Leads to:

Type 'TZDate' is not assignable to type 'ResultDate'.
  'TZDate' is assignable to the constraint of type 'ResultDate', but 'ResultDate' could be instantiated with a different subtype of constraint 'Date'.

The function itself does work as expected, as seen in this sandbox, and the output is consistent with using UTCDate or similar to define the date. So this looks like a typing issue, rather than a functional one?

The docs seem to indicate that this should be fine, so I don't believe I'm doing anything crazy here :D

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

No branches or pull requests

1 participant