Skip to content

Commit 0150c3b

Browse files
committed
This might be a better solution - fix QUnitType and add ManipulateQType
1 parent bf419cf commit 0150c3b

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

types/index.d.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ declare namespace dayjs {
2727

2828
export type UnitType = UnitTypeLong | UnitTypeLongPlural | UnitTypeShort;
2929

30+
type WithQuarters<T> = T & 'quarter' | 'quarters' | 'Q';
31+
3032
export type OpUnitType = UnitType | "week" | "weeks" | 'w';
31-
export type QUnitType = UnitType | "quarter" | "quarters" | 'Q';
33+
export type QUnitType = WithQuarters<OpUnitType>;
34+
3235
export type ManipulateType = Exclude<OpUnitType, 'date' | 'dates'>;
36+
export type ManipulateQType = WithQuarters<ManipulateType>;
37+
3338
class Dayjs {
3439
constructor (config?: ConfigType)
3540
/**

types/plugin/quarterOfYear.d.ts

+8-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
PluginFunc,
3-
ConfigType,
4-
ManipulateType,
5-
QUnitType,
6-
OpUnitType
7-
} from 'dayjs'
1+
import { PluginFunc, ConfigType, ManipulateQType, QUnitType } from 'dayjs'
82

93
declare const plugin: PluginFunc
104
export = plugin
@@ -15,18 +9,18 @@ declare module 'dayjs' {
159

1610
quarter(quarter: number): Dayjs
1711

18-
add(value: number, unit: QUnitType | ManipulateType): Dayjs
12+
add(value: number, unit: ManipulateQType): Dayjs
1913

20-
subtract(value: number, unit: QUnitType | ManipulateType): Dayjs
14+
subtract(value: number, unit: ManipulateQType): Dayjs
2115

22-
startOf(unit: QUnitType | OpUnitType): Dayjs
16+
startOf(unit: QUnitType): Dayjs
2317

24-
endOf(unit: QUnitType | OpUnitType): Dayjs
18+
endOf(unit: QUnitType): Dayjs
2519

26-
isSame(date?: ConfigType, unit?: QUnitType | OpUnitType): boolean
20+
isSame(date?: ConfigType, unit?: QUnitType): boolean
2721

28-
isBefore(date?: ConfigType, unit?: QUnitType | OpUnitType): boolean
22+
isBefore(date?: ConfigType, unit?: QUnitType): boolean
2923

30-
isAfter(date?: ConfigType, unit?: QUnitType | OpUnitType): boolean
24+
isAfter(date?: ConfigType, unit?: QUnitType): boolean
3125
}
3226
}

0 commit comments

Comments
 (0)