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

Definition of ManipulateType and breaks type safety for add #1863

Closed
SpencerKaiser opened this issue Apr 19, 2022 · 2 comments · Fixed by #1864
Closed

Definition of ManipulateType and breaks type safety for add #1863

SpencerKaiser opened this issue Apr 19, 2022 · 2 comments · Fixed by #1864
Labels

Comments

@SpencerKaiser
Copy link
Contributor

Describe the bug
day.add does not have valid type safety because of the ManipulateType type

Expected behavior
Passing an invalid unit to dayjs.add will result in a type error.

Information

  • Day.js Version [1.11.1]
  • OS: [macOS 12.3.1]
  • Browser [N/A]
  • Time zone: [CDT]

Repro:

dayjs().add(4, 'millenniums') // Should result in: Type '"millenniums"' is not assignable to type 'ManipulateType'
// const nope: OpUnitType = 'millenniums'; // ❌ Type '"millenniums"' is not assignable to type 'OpUnitType'
@SpencerKaiser
Copy link
Contributor Author

This is caused by the omit, which cannot be used with unions. Example:
image

@iamkun
Copy link
Owner

iamkun commented May 6, 2022

🎉 This issue has been resolved in version 1.11.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@iamkun iamkun added the released label May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants