Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: convert audit types to modules #12870

Merged
merged 2 commits into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lighthouse-core/audits/critical-request-chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class CriticalRequestChains extends Audit {
};
}

/** @typedef {{depth: number, id: string, chainDuration: number, chainTransferSize: number, node: LH.Audit.SimpleCriticalRequestNode[string]}} CrcNodeInfo */
/** @typedef {{depth: number, id: string, chainDuration: number, chainTransferSize: number, node: LH.Audit.Details.SimpleCriticalRequestNode[string]}} CrcNodeInfo */

/**
* @param {LH.Audit.SimpleCriticalRequestNode} tree
* @param {LH.Audit.Details.SimpleCriticalRequestNode} tree
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going through all of our d.ts files, this was the only type change that needed to happen in a JS file. SimpleCriticalRequestNode really is an audit details type, it just predates the file audit-details.d.ts. Moving it to audit-details avoids a circular dependency of audit-details.d.ts back to SimpleCriticalRequestNode in audit.d.ts.

* @param {function(CrcNodeInfo): void} cb
*/
static _traverse(tree, cb) {
/**
* @param {LH.Audit.SimpleCriticalRequestNode} node
* @param {LH.Audit.Details.SimpleCriticalRequestNode} node
* @param {number} depth
* @param {number=} startTime
* @param {number=} transferSize
Expand Down Expand Up @@ -87,7 +87,7 @@ class CriticalRequestChains extends Audit {

/**
* Get stats about the longest initiator chain (as determined by time duration)
* @param {LH.Audit.SimpleCriticalRequestNode} tree
* @param {LH.Audit.Details.SimpleCriticalRequestNode} tree
* @return {{duration: number, length: number, transferSize: number}}
*/
static _getLongestChain(tree) {
Expand All @@ -111,12 +111,12 @@ class CriticalRequestChains extends Audit {

/**
* @param {LH.Artifacts.CriticalRequestNode} tree
* @return {LH.Audit.SimpleCriticalRequestNode}
* @return {LH.Audit.Details.SimpleCriticalRequestNode}
*/
static flattenRequests(tree) {
/** @type {LH.Audit.SimpleCriticalRequestNode} */
/** @type {LH.Audit.Details.SimpleCriticalRequestNode} */
const flattendChains = {};
/** @type {Map<string, LH.Audit.SimpleCriticalRequestNode[string]>} */
/** @type {Map<string, LH.Audit.Details.SimpleCriticalRequestNode[string]>} */
const chainMap = new Map();

/** @param {CrcNodeInfo} opts */
Expand All @@ -143,7 +143,7 @@ class CriticalRequestChains extends Audit {
if (opts.node.children) {
for (const chainId of Object.keys(opts.node.children)) {
// Note: cast should be Partial<>, but filled in when child node is traversed.
const childChain = /** @type {LH.Audit.SimpleCriticalRequestNode[string]} */ ({
const childChain = /** @type {LH.Audit.Details.SimpleCriticalRequestNode[string]} */ ({
request: {},
});
chainMap.set(chainId, childChain);
Expand Down Expand Up @@ -174,7 +174,7 @@ class CriticalRequestChains extends Audit {
return ComputedChains.request({devtoolsLog, trace, URL}, context).then(chains => {
let chainCount = 0;
/**
* @param {LH.Audit.SimpleCriticalRequestNode} node
* @param {LH.Audit.Details.SimpleCriticalRequestNode} node
* @param {number} depth
*/
function walk(node, depth) {
Expand Down
8 changes: 4 additions & 4 deletions report/renderer/crc-details-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {Util} from './util.js';
export class CriticalRequestChainRenderer {
/**
* Create render context for critical-request-chain tree display.
* @param {LH.Audit.SimpleCriticalRequestNode} tree
* @return {{tree: LH.Audit.SimpleCriticalRequestNode, startTime: number, transferSize: number}}
* @param {LH.Audit.Details.SimpleCriticalRequestNode} tree
* @return {{tree: LH.Audit.Details.SimpleCriticalRequestNode, startTime: number, transferSize: number}}
*/
static initTree(tree) {
let startTime = 0;
Expand All @@ -48,7 +48,7 @@ export class CriticalRequestChainRenderer {
* parent. Calculates if this node is the last child, whether it has any
* children itself and what the tree looks like all the way back up to the root,
* so the tree markers can be drawn correctly.
* @param {LH.Audit.SimpleCriticalRequestNode} parent
* @param {LH.Audit.Details.SimpleCriticalRequestNode} parent
* @param {string} id
* @param {number} startTime
* @param {number} transferSize
Expand Down Expand Up @@ -194,7 +194,7 @@ export class CriticalRequestChainRenderer {
const CRCRenderer = CriticalRequestChainRenderer;

/** @typedef {{
node: LH.Audit.SimpleCriticalRequestNode[string],
node: LH.Audit.Details.SimpleCriticalRequestNode[string],
isLastChild: boolean,
hasChildren: boolean,
startTime: number,
Expand Down
Loading