Skip to content

Commit a923d47

Browse files
committed
Adjust roundToX types
1 parent 1cf2983 commit a923d47

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

src/roundToNearestHours/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { getRoundingMethod } from "../_lib/getRoundingMethod/index.js";
22
import { constructFrom } from "../constructFrom/index.js";
33
import { toDate } from "../toDate/index.js";
4-
import type { NearestHoursOptions, RoundingOptions } from "../types";
4+
import type {
5+
NearestHours,
6+
NearestToUnitOptions,
7+
RoundingOptions,
8+
} from "../types.js";
59

610
/**
711
* The {@link roundToNearestHours} function options.
812
*/
913
export interface RoundToNearestHoursOptions
10-
extends NearestHoursOptions,
14+
extends NearestToUnitOptions<NearestHours>,
1115
RoundingOptions {}
1216

1317
/**

src/roundToNearestMinutes/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { getRoundingMethod } from "../_lib/getRoundingMethod/index.js";
22
import { constructFrom } from "../constructFrom/index.js";
33
import { toDate } from "../toDate/index.js";
4-
import type { NearestMinutesOptions, RoundingOptions } from "../types.js";
4+
import type {
5+
NearestMinutes,
6+
NearestToUnitOptions,
7+
RoundingOptions,
8+
} from "../types.js";
59

610
/**
711
* The {@link roundToNearestMinutes} function options.
812
*/
913
export interface RoundToNearestMinutesOptions
10-
extends NearestMinutesOptions,
14+
extends NearestToUnitOptions<NearestMinutes>,
1115
RoundingOptions {}
1216

1317
/**

src/types.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,20 +280,24 @@ export type NearestMinutes =
280280
| 29
281281
| 30;
282282

283-
/**
284-
* The nearest minutes function options. Used to build function options.
285-
*/
286-
export interface NearestMinutesOptions {
287-
/** The nearest number of minutes to round to. E.g. `15` to round to quarter hours. */
288-
nearestTo?: NearestMinutes;
289-
}
290-
291283
/**
292284
* Nearest hour type. Goes from 1 to 12, where 1 is the nearest hour and 12
293285
* is nearest half a day.
294286
*/
295287
export type NearestHours = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
296288

297-
export interface NearestHoursOptions {
298-
nearestTo?: NearestHours;
289+
/**
290+
* The nearest minutes function options. Used to build function options.
291+
*
292+
* @deprecated Use {@link NearestToUnitOptions} instead.
293+
*/
294+
export type NearestMinutesOptions = NearestToUnitOptions<NearestMinutes>;
295+
296+
/**
297+
* The nearest unit function options. Used to build function options.
298+
*/
299+
export interface NearestToUnitOptions<Unit extends number> {
300+
/** The nearest unit to round to. E.g. for minutes `15` to round to quarter
301+
* hours. */
302+
nearestTo?: Unit;
299303
}

0 commit comments

Comments
 (0)