@@ -4681,17 +4681,15 @@ export function RoundDuration(
4681
4681
let nanoseconds = bigInt ( nanosecondsParam ) ;
4682
4682
const TemporalDuration = GetIntrinsic ( '%Temporal.Duration%' ) ;
4683
4683
let calendar , zdtRelative ;
4684
- // if it's a ZDT, it will be reassigned to a PDT below.
4685
- let relativeTo : Parameters < typeof MoveRelativeDate > [ 1 ] = relativeToParam ;
4686
- if ( relativeToParam ) {
4684
+ // A cast is used below because relativeTo will be either PlainDate or
4685
+ // undefined for the rest of this long method (after any ZDT=>PlainDate
4686
+ // conversion below), and TS isn't smart enough to know that the type has
4687
+ // changed. See https://github.com/microsoft/TypeScript/issues/27706.
4688
+ let relativeTo = relativeToParam as Temporal . PlainDate | undefined ;
4689
+ if ( relativeTo ) {
4687
4690
if ( IsTemporalZonedDateTime ( relativeTo ) ) {
4688
4691
zdtRelative = relativeTo ;
4689
- const pdt = BuiltinTimeZoneGetPlainDateTimeFor (
4690
- GetSlot ( relativeTo , TIME_ZONE ) ,
4691
- GetSlot ( relativeTo , INSTANT ) ,
4692
- GetSlot ( relativeTo , CALENDAR )
4693
- ) ;
4694
- relativeTo = TemporalDateTimeToDate ( pdt ) ;
4692
+ relativeTo = ToTemporalDate ( relativeTo ) ;
4695
4693
} else if ( ! IsTemporalDate ( relativeTo ) ) {
4696
4694
throw new TypeError ( 'starting point must be PlainDate or ZonedDateTime' ) ;
4697
4695
}
0 commit comments