Skip to content

Commit

Permalink
placate ts
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Mar 13, 2018
1 parent c2e25b5 commit b4ac5f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lighthouse-core/report/v2/renderer/report-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class ReportRenderer {
// If any mutations happen to the report within the renderers, we want the original object untouched
const clone = /** @type {!ReportRenderer.ReportJSON} */ (JSON.parse(JSON.stringify(report)));

if (!Array.isArray(report.reportCategories)) throw new Error('No reportCategories provided.');
ReportRenderer.smooshAuditResultsIntoCategories(report.audits, report.reportCategories);
if (!Array.isArray(clone.reportCategories)) throw new Error('No reportCategories provided.');
ReportRenderer.smooshAuditResultsIntoCategories(clone.audits, clone.reportCategories);

container.textContent = ''; // Remove previous report.
const element = container.appendChild(this._renderReport(clone));
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/scoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class ReportScoring {
/**
* Computes the weighted-average of the score of the list of items.
* @param {!Array<{score: number|undefined, weight: number|undefined}>} items
* @param {!Array<{score: ?number|boolean|undefined, weight: number|undefined}>} items
* @return {number}
*/
static arithmeticMean(items) {
Expand Down Expand Up @@ -39,14 +39,14 @@ class ReportScoring {
* Returns the report JSON object with computed scores.
* @param {{categories: !Object<string, {id: string|undefined, weight: number|undefined, score: number|undefined, audits: !Array<{id: string, weight: number|undefined}>}>}} config
* @param {!Object<string, {score: ?number|boolean|undefined, notApplicable: boolean, informative: boolean}>} resultsByAuditId
* @return {{score: number, categories: !Array<{audits: !Array<{score: number, result: !Object}>}>}}
*/
static scoreAllCategories(config, resultsByAuditId) {
for (const [categoryId, category] of Object.entries(config.categories)) {
category.id = categoryId;
category.audits.forEach(audit => {
const result = resultsByAuditId[audit.id];
// Cast to number to catch `null` and undefined when audits error
/** @type {number|boolean} */
let auditScore = Number(result.score) || 0;
if (typeof result.score === 'boolean') {
// HACK removed in the next PR
Expand Down

0 comments on commit b4ac5f0

Please sign in to comment.