@@ -214,7 +214,7 @@ const getUserTimings = (currPage: Page, options: ChartOptions) => {
214
214
name = escapeHtml ( name ) ;
215
215
216
216
if ( fullName !== name && currPage [ `_userTime.endTimer-${ name } ` ] ) {
217
- duration = currPage [ `_userTime.endTimer-${ name } ` ] - currPage [ k ] ;
217
+ duration = currPage [ `_userTime.endTimer-${ name } ` ] as number - currPage [ k ] ;
218
218
return {
219
219
duration,
220
220
name : `${ options . showUserTimingEndMarker ? fullName : name } (${ currPage [ k ] } - ${ currPage [ k ] + duration } ms)` ,
@@ -279,18 +279,19 @@ const buildDetailTimingBlocks = (startRelative: number, harEntry: Entry): Waterf
279
279
* @param {number } startRelative - Number of milliseconds since page load started (`page.startedDateTime`)
280
280
* @returns {Object }
281
281
*/
282
- const getTimePair = ( key : string , harEntry : Entry , collect : WaterfallEntryTiming [ ] , startRelative : number ) => {
283
- let wptKey ;
282
+ const getTimePair = ( key : TimingType , harEntry : Entry , collect : WaterfallEntryTiming [ ] , startRelative : number ) => {
283
+ let wptKey : Exclude < TimingType , 'wait' | 'receive' > | 'ttfb' | 'download' ;
284
+
284
285
switch ( key ) {
285
286
case "wait" : wptKey = "ttfb" ; break ;
286
287
case "receive" : wptKey = "download" ; break ;
287
288
default : wptKey = key ;
288
289
}
289
- const preciseStart = parseInt ( harEntry [ `_${ wptKey } _start` ] , 10 ) ;
290
- const preciseEnd = parseInt ( harEntry [ `_${ wptKey } _end` ] , 10 ) ;
290
+ const preciseStart = parseInt ( ` ${ harEntry [ `_${ wptKey } _start` ] } ` , 10 ) ;
291
+ const preciseEnd = parseInt ( ` ${ harEntry [ `_${ wptKey } _end` ] } ` , 10 ) ;
291
292
const start = isNaN ( preciseStart ) ?
292
- ( ( collect . length > 0 ) ? collect [ collect . length - 1 ] . end : startRelative ) : preciseStart ;
293
- const end = isNaN ( preciseEnd ) ? ( start + harEntry . timings [ key ] ) : preciseEnd ;
293
+ ( ( collect . length > 0 ) ? collect [ collect . length - 1 ] . end : startRelative ) : preciseStart ;
294
+ const end = isNaN ( preciseEnd ) ? ( start + ( harEntry . timings [ key ] ?? 0 ) ) : preciseEnd ;
294
295
295
296
return {
296
297
end : Math . round ( end ) ,
0 commit comments