Skip to content

Commit

Permalink
refactor typing
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Jul 6, 2023
1 parent 315a9f7 commit e52106a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/computed/metrics/cumulative-layout-shift.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ class CumulativeLayoutShift {
return allFrameShiftEvents.some(lse => lse.event === event);
});
await processor.parse(filteredTrace);
const data = /** @type {{LayoutShifts: {sessionMaxScore: number}}} */ (processor.data);
const data = /** @type {import('../../lib/cdt/SDK.js').TraceProcessorResult} */ (
processor.data);
cumulativeLayoutShift = data.LayoutShifts.sessionMaxScore;
} catch (e) {
// Something failed, so fallback to our own implementation.
Expand Down
3 changes: 3 additions & 0 deletions core/lib/cdt/SDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const SDK = {
TraceHandlers: require('./generated/models/trace/handlers/handlers.js').ModelHandlers,
};

/** @typedef {{sessionMaxScore: number}} LayoutShiftsHandler */
/** @typedef {{LayoutShifts: LayoutShiftsHandler}} TraceProcessorResult */

// Add `lastColumnNumber` to mappings. This will eventually be added to CDT.
// @ts-expect-error
SDK.SourceMap.prototype.computeLastGeneratedColumns = function() {
Expand Down

0 comments on commit e52106a

Please sign in to comment.