From 6279102b5b6a8a026c76da3bf7eb905cb6efd9e4 Mon Sep 17 00:00:00 2001 From: Brendan Kenny Date: Mon, 4 Feb 2019 17:25:28 -0800 Subject: [PATCH 1/3] core(tsc): begin clean up of audit details types --- lighthouse-core/audits/audit.js | 6 +-- .../byte-efficiency/byte-efficiency-audit.js | 2 +- .../efficient-animated-content.js | 2 +- .../byte-efficiency/offscreen-images.js | 2 +- .../render-blocking-resources.js | 2 +- .../audits/byte-efficiency/unminified-css.js | 2 +- .../byte-efficiency/unminified-javascript.js | 2 +- .../byte-efficiency/unused-css-rules.js | 2 +- .../byte-efficiency/uses-optimized-images.js | 2 +- .../byte-efficiency/uses-responsive-images.js | 2 +- .../byte-efficiency/uses-text-compression.js | 2 +- .../byte-efficiency/uses-webp-images.js | 2 +- lighthouse-core/audits/redirects.js | 2 +- lighthouse-core/audits/time-to-first-byte.js | 2 +- lighthouse-core/audits/uses-rel-preconnect.js | 2 +- lighthouse-core/audits/uses-rel-preload.js | 2 +- .../html/renderer/crc-details-renderer.js | 12 +----- .../report/html/renderer/details-renderer.js | 15 ++----- .../renderer/performance-category-renderer.js | 3 +- .../renderer/crc-details-renderer-test.js | 1 - types/audit.d.ts | 2 +- types/lhr-lite.d.ts | 41 +------------------ types/lhr.d.ts | 14 ------- 23 files changed, 27 insertions(+), 97 deletions(-) diff --git a/lighthouse-core/audits/audit.js b/lighthouse-core/audits/audit.js index 9eff46f948f9..cd5e10b4a337 100644 --- a/lighthouse-core/audits/audit.js +++ b/lighthouse-core/audits/audit.js @@ -126,11 +126,11 @@ class Audit { } /** - * @param {Array} headings - * @param {Array|Array} items + * @param {Array} headings + * @param {Array} items * @param {number} overallSavingsMs * @param {number=} overallSavingsBytes - * @return {LH.Result.Audit.OpportunityDetails} + * @return {LH.Audit.Details.Opportunity} */ static makeOpportunityDetails(headings, items, overallSavingsMs, overallSavingsBytes) { return { diff --git a/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js b/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js index 4d90e2e2475e..792cd8c84ce9 100644 --- a/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +++ b/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js @@ -27,7 +27,7 @@ const WASTED_MS_FOR_SCORE_OF_ZERO = 5000; /** * @typedef {object} ByteEfficiencyProduct * @property {Array} items - * @property {LH.Result.Audit.OpportunityDetails['headings']} headings + * @property {LH.Audit.Details.Opportunity['headings']} headings * @property {string} [displayValue] * @property {string} [explanation] * @property {Array} [warnings] diff --git a/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js b/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js index 27483d87f39c..bd4c938dcb61 100644 --- a/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js +++ b/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js @@ -74,7 +74,7 @@ class EfficientAnimatedContent extends ByteEfficiencyAudit { }; }); - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, {key: 'totalBytes', valueType: 'bytes', label: str_(i18n.UIStrings.columnSize)}, diff --git a/lighthouse-core/audits/byte-efficiency/offscreen-images.js b/lighthouse-core/audits/byte-efficiency/offscreen-images.js index 79472b92d00d..b4f40ac0e9cf 100644 --- a/lighthouse-core/audits/byte-efficiency/offscreen-images.js +++ b/lighthouse-core/audits/byte-efficiency/offscreen-images.js @@ -223,7 +223,7 @@ class OffscreenImages extends ByteEfficiencyAudit { await TraceOfTab.request(trace, context).then(tot => tot.timestamps.traceEnd)); } - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'thumbnail', label: ''}, {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, diff --git a/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js b/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js index 5e1e17e65633..8400d3affb57 100644 --- a/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js +++ b/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js @@ -211,7 +211,7 @@ class RenderBlockingResources extends Audit { displayValue = str_(i18n.UIStrings.displayValueMsSavings, {wastedMs}); } - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, {key: 'totalBytes', valueType: 'bytes', label: str_(i18n.UIStrings.columnSize)}, diff --git a/lighthouse-core/audits/byte-efficiency/unminified-css.js b/lighthouse-core/audits/byte-efficiency/unminified-css.js index c5ec4a95429e..87604f5def44 100644 --- a/lighthouse-core/audits/byte-efficiency/unminified-css.js +++ b/lighthouse-core/audits/byte-efficiency/unminified-css.js @@ -102,7 +102,7 @@ class UnminifiedCSS extends ByteEfficiencyAudit { items.push(result); } - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, {key: 'totalBytes', valueType: 'bytes', label: str_(i18n.UIStrings.columnSize)}, diff --git a/lighthouse-core/audits/byte-efficiency/unminified-javascript.js b/lighthouse-core/audits/byte-efficiency/unminified-javascript.js index 441a297334bd..364af573f82a 100644 --- a/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +++ b/lighthouse-core/audits/byte-efficiency/unminified-javascript.js @@ -95,7 +95,7 @@ class UnminifiedJavaScript extends ByteEfficiencyAudit { } } - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, {key: 'totalBytes', valueType: 'bytes', label: str_(i18n.UIStrings.columnSize)}, diff --git a/lighthouse-core/audits/byte-efficiency/unused-css-rules.js b/lighthouse-core/audits/byte-efficiency/unused-css-rules.js index 1c2adbb99501..475d8657a2aa 100644 --- a/lighthouse-core/audits/byte-efficiency/unused-css-rules.js +++ b/lighthouse-core/audits/byte-efficiency/unused-css-rules.js @@ -173,7 +173,7 @@ class UnusedCSSRules extends ByteEfficiencyAudit { .map(sheetId => UnusedCSSRules.mapSheetToResult(indexedSheets[sheetId], pageUrl)) .filter(sheet => sheet && sheet.wastedBytes > IGNORE_THRESHOLD_IN_BYTES); - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, {key: 'totalBytes', valueType: 'bytes', label: str_(i18n.UIStrings.columnSize)}, diff --git a/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js b/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js index 0ffd9a7e81cc..2d4b085164ad 100644 --- a/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js +++ b/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js @@ -80,7 +80,7 @@ class UsesOptimizedImages extends ByteEfficiencyAudit { }); } - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'thumbnail', label: ''}, {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, diff --git a/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js b/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js index 9769ca6ca5a9..139f26c733a2 100644 --- a/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +++ b/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js @@ -119,7 +119,7 @@ class UsesResponsiveImages extends ByteEfficiencyAudit { const items = Array.from(resultsMap.values()) .filter(item => item.wastedBytes > IGNORE_THRESHOLD_IN_BYTES); - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'thumbnail', label: ''}, {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, diff --git a/lighthouse-core/audits/byte-efficiency/uses-text-compression.js b/lighthouse-core/audits/byte-efficiency/uses-text-compression.js index aa706f66f5ad..a400dca3cac8 100644 --- a/lighthouse-core/audits/byte-efficiency/uses-text-compression.js +++ b/lighthouse-core/audits/byte-efficiency/uses-text-compression.js @@ -82,7 +82,7 @@ class ResponsesAreCompressed extends ByteEfficiencyAudit { }); }); - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, {key: 'totalBytes', valueType: 'bytes', label: str_(i18n.UIStrings.columnSize)}, diff --git a/lighthouse-core/audits/byte-efficiency/uses-webp-images.js b/lighthouse-core/audits/byte-efficiency/uses-webp-images.js index 56e58a2a6028..fb681dd3ac40 100644 --- a/lighthouse-core/audits/byte-efficiency/uses-webp-images.js +++ b/lighthouse-core/audits/byte-efficiency/uses-webp-images.js @@ -79,7 +79,7 @@ class UsesWebPImages extends ByteEfficiencyAudit { }); } - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'thumbnail', label: ''}, {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, diff --git a/lighthouse-core/audits/redirects.js b/lighthouse-core/audits/redirects.js index fd1a4bcd18f0..a2b1c74564a9 100644 --- a/lighthouse-core/audits/redirects.js +++ b/lighthouse-core/audits/redirects.js @@ -98,7 +98,7 @@ class Redirects extends Audit { }); } - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, {key: 'wastedMs', valueType: 'timespanMs', label: str_(i18n.UIStrings.columnTimeSpent)}, diff --git a/lighthouse-core/audits/time-to-first-byte.js b/lighthouse-core/audits/time-to-first-byte.js index 928e17dd916a..ec6610ff2588 100644 --- a/lighthouse-core/audits/time-to-first-byte.js +++ b/lighthouse-core/audits/time-to-first-byte.js @@ -60,7 +60,7 @@ class TTFBMetric extends Audit { const passed = ttfb < TTFB_THRESHOLD; const displayValue = str_(UIStrings.displayValue, {timeInMs: ttfb}); - /** @type {LH.Result.Audit.OpportunityDetails} */ + /** @type {LH.Audit.Details.Opportunity} */ const details = { type: 'opportunity', overallSavingsMs: ttfb - TTFB_THRESHOLD, diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index 0f09b12d9ab5..e08620b251a0 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -178,7 +178,7 @@ class UsesRelPreconnectAudit extends Audit { results = results .sort((a, b) => b.wastedMs - a.wastedMs); - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, {key: 'wastedMs', valueType: 'timespanMs', label: str_(i18n.UIStrings.columnWastedMs)}, diff --git a/lighthouse-core/audits/uses-rel-preload.js b/lighthouse-core/audits/uses-rel-preload.js index e79680c559db..671e2ffea579 100644 --- a/lighthouse-core/audits/uses-rel-preload.js +++ b/lighthouse-core/audits/uses-rel-preload.js @@ -213,7 +213,7 @@ class UsesRelPreloadAudit extends Audit { .map(preloadURL => str_(UIStrings.crossoriginWarning, {preloadURL})); } - /** @type {LH.Result.Audit.OpportunityDetails['headings']} */ + /** @type {LH.Audit.Details.Opportunity['headings']} */ const headings = [ {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)}, {key: 'wastedMs', valueType: 'timespanMs', label: str_(i18n.UIStrings.columnWastedMs)}, diff --git a/lighthouse-core/report/html/renderer/crc-details-renderer.js b/lighthouse-core/report/html/renderer/crc-details-renderer.js index 9ffde2295287..150064d477f2 100644 --- a/lighthouse-core/report/html/renderer/crc-details-renderer.js +++ b/lighthouse-core/report/html/renderer/crc-details-renderer.js @@ -145,7 +145,7 @@ class CriticalRequestChainRenderer { * @param {DocumentFragment} tmpl * @param {CRCSegment} segment * @param {Element} elem Parent element. - * @param {CRCDetailsJSON} details + * @param {LH.Audit.Details.CriticalRequestChain} details */ static buildTree(dom, tmpl, segment, elem, details) { elem.appendChild(CriticalRequestChainRenderer.createChainNode(dom, tmpl, segment)); @@ -161,7 +161,7 @@ class CriticalRequestChainRenderer { /** * @param {DOM} dom * @param {ParentNode} templateContext - * @param {CRCDetailsJSON} details + * @param {LH.Audit.Details.CriticalRequestChain} details * @return {Element} */ static render(dom, templateContext, details) { @@ -194,14 +194,6 @@ if (typeof module !== 'undefined' && module.exports) { self.CriticalRequestChainRenderer = CriticalRequestChainRenderer; } -/** @typedef {{ - type: string, - header: {text: string}, - longestChain: {duration: number, length: number, transferSize: number}, - chains: LH.Audit.SimpleCriticalRequestNode - }} CRCDetailsJSON - */ - /** @typedef {{ node: LH.Audit.SimpleCriticalRequestNode[string], isLastChild: boolean, diff --git a/lighthouse-core/report/html/renderer/details-renderer.js b/lighthouse-core/report/html/renderer/details-renderer.js index b440662f3b8b..9526be1303e5 100644 --- a/lighthouse-core/report/html/renderer/details-renderer.js +++ b/lighthouse-core/report/html/renderer/details-renderer.js @@ -19,8 +19,7 @@ /* globals self CriticalRequestChainRenderer Util URL */ /** @typedef {import('./dom.js')} DOM */ -/** @typedef {import('./crc-details-renderer.js')} CRCDetailsJSON */ -/** @typedef {LH.Result.Audit.OpportunityDetails} OpportunityDetails */ +/** @typedef {LH.Audit.Details.Opportunity} OpportunityDetails */ /** @type {Array} */ const URL_PREFIXES = ['http://', 'https://', 'data:']; @@ -76,7 +75,7 @@ class DetailsRenderer { case 'criticalrequestchain': return CriticalRequestChainRenderer.render(this._dom, this._templateContext, // @ts-ignore - TODO(bckenny): Fix type hierarchy - /** @type {CRCDetailsJSON} */ (details)); + /** @type {LH.Audit.Details.CriticalRequestChain} */ (details)); case 'opportunity': // @ts-ignore - TODO(bckenny): Fix type hierarchy return this._renderOpportunityTable(details); @@ -289,7 +288,7 @@ class DetailsRenderer { for (const row of details.items) { const rowElem = this._dom.createChildOf(tbodyElem, 'tr'); for (const heading of details.headings) { - const key = /** @type {keyof LH.Result.Audit.OpportunityDetailsItem} */ (heading.key); + const key = /** @type {keyof LH.Audit.Details.OpportunityItem} */ (heading.key); const value = row[key]; if (typeof value === 'undefined' || value === null) { @@ -360,7 +359,7 @@ class DetailsRenderer { } /** - * @param {FilmstripDetails} details + * @param {LH.Audit.Details.Filmstrip} details * @return {Element} */ _renderFilmstrip(details) { @@ -460,9 +459,3 @@ if (typeof module !== 'undefined' && module.exports) { }} LinkDetailsJSON */ -/** @typedef {{ - type: string, - scale: number, - items: Array<{timing: number, timestamp: number, data: string}>, - }} FilmstripDetails - */ diff --git a/lighthouse-core/report/html/renderer/performance-category-renderer.js b/lighthouse-core/report/html/renderer/performance-category-renderer.js index 870bdfc4e79d..8d63094bc40e 100644 --- a/lighthouse-core/report/html/renderer/performance-category-renderer.js +++ b/lighthouse-core/report/html/renderer/performance-category-renderer.js @@ -19,8 +19,7 @@ /* globals self, Util, CategoryRenderer */ /** @typedef {import('./dom.js')} DOM */ -/** @typedef {import('./details-renderer.js').FilmstripDetails} FilmstripDetails */ -/** @typedef {LH.Result.Audit.OpportunityDetails} OpportunityDetails */ +/** @typedef {LH.Audit.Details.Opportunity} OpportunityDetails */ class PerformanceCategoryRenderer extends CategoryRenderer { /** diff --git a/lighthouse-core/test/report/html/renderer/crc-details-renderer-test.js b/lighthouse-core/test/report/html/renderer/crc-details-renderer-test.js index 1d5c1cb64ad5..1cf2564a6ee2 100644 --- a/lighthouse-core/test/report/html/renderer/crc-details-renderer-test.js +++ b/lighthouse-core/test/report/html/renderer/crc-details-renderer-test.js @@ -23,7 +23,6 @@ const superLongURL = 'https://example.com/thisIsASuperLongURLThatWillTriggerFilenameTruncationWhichWeWantToTest.js'; const DETAILS = { type: 'criticalrequestchain', - header: {type: 'text', text: 'CRC Header'}, chains: { 0: { request: { diff --git a/types/audit.d.ts b/types/audit.d.ts index 1fb2b36ff18e..b57bb71a98aa 100644 --- a/types/audit.d.ts +++ b/types/audit.d.ts @@ -63,7 +63,7 @@ declare global { granularity?: number; } - export interface ByteEfficiencyItem extends Result.Audit.OpportunityDetailsItem { + export interface ByteEfficiencyItem extends Audit.Details.OpportunityItem { url: string; wastedBytes: number; totalBytes: number; diff --git a/types/lhr-lite.d.ts b/types/lhr-lite.d.ts index 8395a6b9cc6e..a8c1251d995f 100644 --- a/types/lhr-lite.d.ts +++ b/types/lhr-lite.d.ts @@ -70,49 +70,10 @@ declare global { /** An explanation of audit-related issues encountered on the test page. */ explanation?: string; /** Extra information provided by some types of audits. */ - details?: Audit.MetricDetails | Audit.OpportunityDetails; + details?: never; /** Error message from any exception thrown while running this audit. */ errorMessage?: string; } - - export module Audit { - export interface MetricDetails { - type: 'metric'; - /** The value of the metric expressed in milliseconds. */ - timespanMs?: number; - } - - export interface OpportunityDetails { - type: 'opportunity'; - overallSavingsMs: number - overallSavingsBytes?: number - headings: ColumnHeading[]; - items: (WastedBytesDetailsItem | WastedTimeDetailsItem)[]; - } - - export interface ColumnHeading { - /** The property key name within DetailsItem being described. */ - key: string; - /** Readable text label of the field. */ - label: string; - // TODO(bckenny): should be just string and let lhr be more specific? - valueType: 'url' | 'timespanMs' | 'bytes' | 'thumbnail'; - } - - export interface WastedBytesDetailsItem { - url: string; - wastedBytes?: number; - totalBytes?: number; - [p: string]: number | boolean | string | undefined; - } - - export interface WastedTimeDetailsItem { - url: string; - wastedMs: number; - totalBytes?: number; - [p: string]: number | boolean | string | undefined; - } - } } } } diff --git a/types/lhr.d.ts b/types/lhr.d.ts index 8c1403f40cc0..d1b25612db85 100644 --- a/types/lhr.d.ts +++ b/types/lhr.d.ts @@ -113,20 +113,6 @@ declare global { blockedUrlPatterns: string[]; extraHeaders: Crdp.Network.Headers; } - - export module Audit { - export interface OpportunityDetailsItem { - url: string; - wastedBytes?: number; - totalBytes?: number; - wastedMs?: number; - [p: string]: number | boolean | string | undefined; - } - - export interface OpportunityDetails extends ResultLite.Audit.OpportunityDetails { - items: OpportunityDetailsItem[]; - } - } } } } From dfbbf89e427d3b84d6168480e8a4d92ef452030f Mon Sep 17 00:00:00 2001 From: Brendan Kenny Date: Mon, 4 Feb 2019 17:34:54 -0800 Subject: [PATCH 2/3] kind of important file --- types/audit-details.d.ts | 71 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 types/audit-details.d.ts diff --git a/types/audit-details.d.ts b/types/audit-details.d.ts new file mode 100644 index 000000000000..53920208fcd2 --- /dev/null +++ b/types/audit-details.d.ts @@ -0,0 +1,71 @@ +/** + * @license Copyright 2019 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +declare global { + module LH.Audit.Details { + export interface Filmstrip { + type: 'filmstrip'; + scale: number; + items: { + timing: number; + timestamp: number; + data: string; + }[]; + } + + export interface Screenshot { + type: 'screenshot'; + timestamp: number; + data: string; + } + + export interface Opportunity { + type: 'opportunity'; + overallSavingsMs: number; + overallSavingsBytes?: number; + headings: TableColumnHeading[]; + items: OpportunityItem[]; + } + + export interface CriticalRequestChain { + type: 'criticalrequestchain'; + longestChain: { + duration: number; + length: number; + transferSize: number; + }; + chains: Audit.SimpleCriticalRequestNode; + } + + // TODO(bckenny) + // export interface MultiCheck {} + // export interface Table {} + // export interface SomeKindOfHiddenThing + + // Contents of details below here + + export interface TableColumnHeading { + /** The name of the property within items being described. */ + key: string; + /** Readable text label of the field. */ + label: string; + // TODO(bckenny): should be just string and let lhr be more specific? + valueType: string; // 'url' | 'timespanMs' | 'bytes' | 'thumbnail'; + } + + export interface OpportunityItem { + url: string; + wastedBytes?: number; + totalBytes?: number; + wastedMs?: number; + [p: string]: number | boolean | string | undefined; + } + + } +} + +// empty export to keep file a module +export {} From 98c972dee2aa741f2f09e5467aabeaaf8519a58e Mon Sep 17 00:00:00 2001 From: Brendan Kenny Date: Mon, 4 Feb 2019 20:16:31 -0800 Subject: [PATCH 3/3] feedback --- lighthouse-core/audits/audit.js | 2 +- types/audit-details.d.ts | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lighthouse-core/audits/audit.js b/lighthouse-core/audits/audit.js index cd5e10b4a337..98b44ba30757 100644 --- a/lighthouse-core/audits/audit.js +++ b/lighthouse-core/audits/audit.js @@ -126,7 +126,7 @@ class Audit { } /** - * @param {Array} headings + * @param {Array} headings * @param {Array} items * @param {number} overallSavingsMs * @param {number=} overallSavingsBytes diff --git a/types/audit-details.d.ts b/types/audit-details.d.ts index 53920208fcd2..dda07549bad2 100644 --- a/types/audit-details.d.ts +++ b/types/audit-details.d.ts @@ -10,8 +10,11 @@ declare global { type: 'filmstrip'; scale: number; items: { + /** The relative time from navigationStart to this frame, in milliseconds. */ timing: number; + /** The raw timestamp of this frame, in microseconds. */ timestamp: number; + /** The data URL encoding of this frame. */ data: string; }[]; } @@ -26,7 +29,7 @@ declare global { type: 'opportunity'; overallSavingsMs: number; overallSavingsBytes?: number; - headings: TableColumnHeading[]; + headings: OpportunityColumnHeading[]; items: OpportunityItem[]; } @@ -40,20 +43,15 @@ declare global { chains: Audit.SimpleCriticalRequestNode; } - // TODO(bckenny) - // export interface MultiCheck {} - // export interface Table {} - // export interface SomeKindOfHiddenThing - // Contents of details below here - export interface TableColumnHeading { + export interface OpportunityColumnHeading { /** The name of the property within items being described. */ key: string; /** Readable text label of the field. */ label: string; - // TODO(bckenny): should be just string and let lhr be more specific? - valueType: string; // 'url' | 'timespanMs' | 'bytes' | 'thumbnail'; + /** The data format of the column of values being described. */ + valueType: string; } export interface OpportunityItem {