Skip to content

fix(types): allow quarter units in isSameOrBefore/isSameOrAfter - #3210

Closed
veerareddyvishal144 wants to merge 1 commit into
iamkun:devfrom
veerareddyvishal144:fix/isSameOr-quarter-types-3192
Closed

veerareddyvishal144 wants to merge 1 commit into
iamkun:devfrom
veerareddyvishal144:fix/isSameOr-quarter-types-3192

Conversation

@veerareddyvishal144

Copy link
Copy Markdown

Fixes #3192

Problem
isSameOrBefore and isSameOrAfter reject 'quarter' | 'quarters' | 'Q' with TS2345 (not assignable to parameter of type 'OpUnitType'), even though the runtime supports quarter granularity once the quarterOfYear plugin is loaded (it patches startOf/endOf, which isSame/isBefore/isAfter delegate to).

Root cause: types/plugin/isSameOrBefore.d.ts and types/plugin/isSameOrAfter.d.ts typed the unit param as OpUnitType only, while types/plugin/quarterOfYear.d.ts already exposes quarter support via QUnitType (and uses QUnitType | OpUnitType for startOf/endOf).

Change

  • types/plugin/isSameOrBefore.d.ts: unit?: OpUnitType -> unit?: QUnitType | OpUnitType
  • types/plugin/isSameOrAfter.d.ts: same

This mirrors the existing startOf/endOf union pattern in quarterOfYear.d.ts.

Verification

  • Reproduced with tsc --strict: 6x TS2345 errors for 'quarter'/'quarters'/'Q' before the fix, 0 after; invalid units (e.g. 'decade') still error via @ts-expect-error check.
  • Runtime check (quarterOfYear + isSameOrBefore/After extended): quarter comparisons return correct results, including 'Q' shorthand.
  • Existing suites pass: isSameOrBefore, isSameOrAfter, quarterOfYear (24 tests).

@veerareddyvishal144

Copy link
Copy Markdown
Author

Closing as duplicate — #3155 already covers #3192. Thanks for catching it; picking up a different issue instead.

@veerareddyvishal144
veerareddyvishal144 deleted the fix/isSameOr-quarter-types-3192 branch September 6, 2026 03:18
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.

TypeScript errors occur when using isSameOrBefore and isSameOrAfter

1 participant