Skip to content

Definition of ManipulateType and breaks type safety for add #1863

@SpencerKaiser

Description

@SpencerKaiser

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions