Skip to content

Commit b58d996

Browse files
committed
Changes from @12wrigja code review comments
1 parent 6747493 commit b58d996

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

lib/ecmascript.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,10 @@ export function ToTemporalDateTimeRoundingIncrement(
744744
smallestUnit: keyof TemporalDateTimeRoundingMaximumIncrements
745745
) {
746746
const maximumIncrements: TemporalDateTimeRoundingMaximumIncrements = {
747-
year: undefined as number | undefined,
748-
month: undefined as number | undefined,
749-
week: undefined as number | undefined,
750-
day: undefined as number | undefined,
747+
year: undefined,
748+
month: undefined,
749+
week: undefined,
750+
day: undefined,
751751
hour: 24,
752752
minute: 60,
753753
second: 60,
@@ -782,7 +782,7 @@ export function ToSecondsStringPrecision(options: Temporal.ToStringPrecisionOpti
782782
if (typeof digits !== 'number') {
783783
const stringDigits = ToString(digits);
784784
if (stringDigits === 'auto') return { precision: 'auto', unit: 'nanosecond', increment: 1 };
785-
throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${digits}`);
785+
throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${stringDigits}`);
786786
}
787787
if (NumberIsNaN(digits) || digits < 0 || digits > 9) {
788788
throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${digits}`);
@@ -808,6 +808,21 @@ export function ToSecondsStringPrecision(options: Temporal.ToStringPrecisionOpti
808808
}
809809
}
810810

811+
export function ToLargestTemporalUnit<Allowed extends Temporal.DateTimeUnit, Disallowed extends Temporal.DateTimeUnit>(
812+
options: { largestUnit?: Temporal.LargestUnitOption<Allowed> },
813+
fallback: Allowed | 'auto',
814+
disallowedStrings?: ReadonlyArray<Disallowed>
815+
): Allowed | 'auto';
816+
export function ToLargestTemporalUnit<
817+
Allowed extends Temporal.DateTimeUnit,
818+
Disallowed extends Temporal.DateTimeUnit,
819+
IfAuto extends Allowed | undefined = Allowed
820+
>(
821+
options: { largestUnit?: Temporal.LargestUnitOption<Allowed> },
822+
fallback: Allowed | 'auto',
823+
disallowedStrings: ReadonlyArray<Disallowed>,
824+
autoValue?: IfAuto
825+
): Allowed;
811826
export function ToLargestTemporalUnit<
812827
Allowed extends Temporal.DateTimeUnit,
813828
Disallowed extends Temporal.DateTimeUnit,
@@ -880,7 +895,8 @@ export function ToRelativeTemporalObject(options: {
880895
| undefined;
881896
}): Temporal.ZonedDateTime | Temporal.PlainDateTime | undefined {
882897
const relativeTo = options.relativeTo;
883-
// TODO: file a bug against TypeScript because `as undefined` below should not be needed.
898+
// TODO: `as undefined` below should not be needed. Verify that it can be
899+
// removed after strictNullChecks is enabled.
884900
if (relativeTo === undefined) return relativeTo as undefined;
885901

886902
let offsetBehaviour: OffsetBehaviour = 'option';

lib/intrinsicclass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function DefineIntrinsic<KeyT extends keyof StandaloneIntrinsics>(
130130
value: StandaloneIntrinsics[KeyT]
131131
): void;
132132
export function DefineIntrinsic<KeyT>(name: KeyT, value: never): void;
133-
export function DefineIntrinsic<KeyT extends IntrinsicDefinitionKeys>(name: KeyT, value: unknown) {
133+
export function DefineIntrinsic<KeyT extends IntrinsicDefinitionKeys>(name: KeyT, value: unknown): void {
134134
const key: `%${IntrinsicDefinitionKeys}%` = `%${name}%`;
135135
if (INTRINSICS[key] !== undefined) throw new Error(`intrinsic ${name} already exists`);
136136
INTRINSICS[key] = value;

0 commit comments

Comments
 (0)