Skip to content

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)

*/

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

Successfully merging this pull request may close these issues.

1 participant