Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix the type of unit parameter of the methods that quarterOfYear plugin extends #2814

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

drylint
Copy link

@drylint drylint commented Jan 20, 2025

Example code:

import dayjs from 'dayjs'
import quarterOfYear from 'dayjs/plugin/quarterOfYear'

dayjs.extend(quarterOfYear)

const _bugsExample = (unit: 'week' | 'quarter') => {
  const dayjsInstance = dayjs()
  dayjsInstance.add(1, unit)
  dayjsInstance.subtract(1, unit)
  dayjsInstance.isSame(Date.now(), unit)
  dayjsInstance.isBefore(Date.now(), unit)
  dayjsInstance.isAfter(Date.now(), unit)
}

All reported the error:

/**

No overload matches this call.
  Overload 1 of 2, '(value: number, unit: QUnitType): Dayjs', gave the following error.
    Argument of type '"week" | "quarter"' is not assignable to parameter of type 'QUnitType'.
      Type '"week"' is not assignable to type 'QUnitType'.
  Overload 2 of 2, '(value: number, unit?: ManipulateType | undefined): Dayjs', gave the following error.
    Argument of type '"week" | "quarter"' is not assignable to parameter of type 'ManipulateType | undefined'.
      Type '"quarter"' is not assignable to type 'ManipulateType | undefined'.ts(2769)

*/

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

Successfully merging this pull request may close these issues.

1 participant