diff --git a/cli/cli-flags.js b/cli/cli-flags.js index 4c6251d4ce3b..17247f88b81b 100644 --- a/cli/cli-flags.js +++ b/cli/cli-flags.js @@ -389,7 +389,7 @@ function coerceOptionalStringBoolean(value) { function coerceOutput(values) { const outputTypes = ['json', 'html', 'csv']; const errorHint = `Argument 'output' must be an array from choices "${outputTypes.join('", "')}"`; - if (!values.every(/** @return {item is string} */ item => typeof item === 'string')) { + if (!values.every(item => typeof item === 'string')) { throw new Error('Invalid values. ' + errorHint); } // Allow parsing of comma-separated values. diff --git a/cli/sentry-prompt.js b/cli/sentry-prompt.js index a22c4ed8acad..afd1d1130630 100644 --- a/cli/sentry-prompt.js +++ b/cli/sentry-prompt.js @@ -26,7 +26,7 @@ function prompt() { return Promise.resolve(false); } - /** @type {NodeJS.Timer|undefined} */ + /** @type {NodeJS.Timeout|undefined} */ let timeout; const prompt = new Confirm.Confirm({ @@ -47,7 +47,7 @@ function prompt() { return Promise.race([ prompt.run().then(result => { - clearTimeout(/** @type {NodeJS.Timer} */ (timeout)); + clearTimeout(timeout); return result; }), timeoutPromise, diff --git a/core/computed/critical-request-chains.js b/core/computed/critical-request-chains.js index 519a67883a82..2792f8ad2828 100644 --- a/core/computed/critical-request-chains.js +++ b/core/computed/critical-request-chains.js @@ -109,8 +109,7 @@ class CriticalRequestChains { if (!CriticalRequestChains.isCritical(node.request, mainResource)) return; const networkPath = traversalPath - .filter(/** @return {n is LH.Gatherer.Simulation.GraphNetworkNode} */ - n => n.type === 'network') + .filter(n => n.type === 'network') .reverse() .map(node => node.rawRequest); diff --git a/core/gather/driver/environment.js b/core/gather/driver/environment.js index 7215dd97ad93..978d47b6eb3a 100644 --- a/core/gather/driver/environment.js +++ b/core/gather/driver/environment.js @@ -93,7 +93,7 @@ function getSlowHostCpuWarning(context) { function getEnvironmentWarnings(context) { return [ getSlowHostCpuWarning(context), - ].filter(/** @return {s is LH.IcuMessage} */ s => !!s); + ].filter(s => !!s); } export { diff --git a/core/gather/driver/wait-for-condition.js b/core/gather/driver/wait-for-condition.js index b110f686c12a..ac5b57f18b14 100644 --- a/core/gather/driver/wait-for-condition.js +++ b/core/gather/driver/wait-for-condition.js @@ -126,7 +126,7 @@ function waitForFcp(session, pauseAfterFcpMs, maxWaitForFcpMs) { */ function waitForNetworkIdle(session, networkMonitor, networkQuietOptions) { let hasDCLFired = false; - /** @type {NodeJS.Timer|undefined} */ + /** @type {NodeJS.Timeout|undefined} */ let idleTimeout; /** @type {(() => void)} */ let cancel = () => { @@ -225,7 +225,7 @@ function waitForCPUIdle(session, waitForCPUQuiet) { }; } - /** @type {NodeJS.Timer|undefined} */ + /** @type {NodeJS.Timeout|undefined} */ let lastTimeout; let canceled = false; @@ -355,7 +355,7 @@ function waitForLoadEvent(session, pauseAfterLoadMs) { }; const promise = new Promise((resolve, reject) => { - /** @type {NodeJS.Timer|undefined} */ + /** @type {NodeJS.Timeout|undefined} */ let loadTimeout; const loadListener = function() { loadTimeout = setTimeout(resolve, pauseAfterLoadMs); @@ -420,7 +420,7 @@ async function waitForFullyLoaded(session, networkMonitor, options) { cpuQuietThresholdMs, maxWaitForLoadedMs, maxWaitForFcpMs} = options; const {waitForFcp, waitForLoadEvent, waitForNetworkIdle, waitForCPUIdle} = options._waitForTestOverrides || DEFAULT_WAIT_FUNCTIONS; - /** @type {NodeJS.Timer|undefined} */ + /** @type {NodeJS.Timeout|undefined} */ let maxTimeoutHandle; // Listener for FCP. Resolves pauseAfterFcpMs ms after first FCP event. diff --git a/core/gather/gatherers/link-elements.js b/core/gather/gatherers/link-elements.js index 9e4c86cf5c09..b3324c32708c 100644 --- a/core/gather/gatherers/link-elements.js +++ b/core/gather/gatherers/link-elements.js @@ -94,18 +94,11 @@ function getLinkElementsInDOM() { /* c8 ignore stop */ class LinkElements extends BaseGatherer { - constructor() { - super(); - /** - * This needs to be in the constructor. - * https://github.com/GoogleChrome/lighthouse/issues/12134 - * @type {LH.Gatherer.GathererMeta<'DevtoolsLog'>} - */ - this.meta = { - supportedModes: ['timespan', 'navigation'], - dependencies: {DevtoolsLog: DevtoolsLog.symbol}, - }; - } + /** @type {LH.Gatherer.GathererMeta<'DevtoolsLog'>} */ + meta = { + supportedModes: ['timespan', 'navigation'], + dependencies: {DevtoolsLog: DevtoolsLog.symbol}, + }; /** * @param {LH.Gatherer.Context} context diff --git a/core/gather/session.js b/core/gather/session.js index b15938c9bd14..8d9bd24ad7af 100644 --- a/core/gather/session.js +++ b/core/gather/session.js @@ -113,7 +113,7 @@ class ProtocolSession extends CrdpEventEmitter { const timeoutMs = this.getNextProtocolTimeout(); this._nextProtocolTimeout = undefined; - /** @type {NodeJS.Timer|undefined} */ + /** @type {NodeJS.Timeout|undefined} */ let timeout; const timeoutPromise = new Promise((resolve, reject) => { // Unexpected setTimeout invocation to preserve the error stack. https://github.com/GoogleChrome/lighthouse/issues/13332 diff --git a/core/lib/cdt/generated/ParsedURL.js b/core/lib/cdt/generated/ParsedURL.js index c966cd82e697..9b10c7ae420d 100644 --- a/core/lib/cdt/generated/ParsedURL.js +++ b/core/lib/cdt/generated/ParsedURL.js @@ -32,7 +32,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.ParsedURL = exports.normalizePath = void 0; +exports.ParsedURL = void 0; +exports.normalizePath = normalizePath; ; /** * http://tools.ietf.org/html/rfc3986#section-5.2.4 @@ -67,7 +68,6 @@ function normalizePath(path) { } return normalizedPath; } -exports.normalizePath = normalizePath; class ParsedURL { isValid; url; diff --git a/core/lib/cdt/generated/SourceMap.js b/core/lib/cdt/generated/SourceMap.js index ef966850ef99..d5e2ebcee2be 100644 --- a/core/lib/cdt/generated/SourceMap.js +++ b/core/lib/cdt/generated/SourceMap.js @@ -8,7 +8,8 @@ const Platform = require('../Platform.js'); // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. Object.defineProperty(exports, "__esModule", { value: true }); -exports.SourceMap = exports.SourceMapEntry = exports.parseSourceMap = void 0; +exports.SourceMap = exports.SourceMapEntry = void 0; +exports.parseSourceMap = parseSourceMap; /* * Copyright (C) 2012 Google Inc. All rights reserved. * @@ -58,7 +59,6 @@ function parseSourceMap(content) { } return JSON.parse(content); } -exports.parseSourceMap = parseSourceMap; class SourceMapEntry { lineNumber; columnNumber; @@ -470,7 +470,7 @@ exports.SourceMap = SourceMap; } } SourceMap.StringCharIterator = StringCharIterator; -})(SourceMap = exports.SourceMap || (exports.SourceMap = {})); +})(SourceMap || (exports.SourceMap = SourceMap = {})); module.exports = SourceMap; diff --git a/core/lib/tracehouse/cpu-profile-model.js b/core/lib/tracehouse/cpu-profile-model.js index 0df07838c1a5..6752ae424406 100644 --- a/core/lib/tracehouse/cpu-profile-model.js +++ b/core/lib/tracehouse/cpu-profile-model.js @@ -140,11 +140,11 @@ class CpuProfileModel { const startNodes = currentNodeIds .filter(id => !previousNodeIds.includes(id)) .map(id => this._nodesById.get(id)) - .filter(/** @return {node is CpuProfile['nodes'][0]} */ node => !!node); + .filter(node => !!node); const endNodes = previousNodeIds .filter(id => !currentNodeIds.includes(id)) .map(id => this._nodesById.get(id)) - .filter(/** @return {node is CpuProfile['nodes'][0]} */ node => !!node); + .filter(node => !!node); /** @param {CpuProfile['nodes'][0]} node @return {SynthethicEvent} */ const createSyntheticEvent = node => ({ diff --git a/core/runner.js b/core/runner.js index 5aecbcd5d12c..ad4ccaeab9e7 100644 --- a/core/runner.js +++ b/core/runner.js @@ -387,7 +387,6 @@ vs // If artifact was an error, output error result on behalf of audit. if (artifacts[artifactName] instanceof Error) { /** @type {Error} */ - // @ts-expect-error: TODO why is this a type error now? const artifactError = artifacts[artifactName]; log.warn('Runner', `${artifactName} gatherer, required by audit ${audit.meta.id},` + diff --git a/core/scripts/i18n/collect-strings.js b/core/scripts/i18n/collect-strings.js index a6ca66163757..8c99b9940c98 100644 --- a/core/scripts/i18n/collect-strings.js +++ b/core/scripts/i18n/collect-strings.js @@ -58,7 +58,7 @@ const ignoredPathComponents = [ /** * Extract the description and examples (if any) from a jsDoc annotation. - * @param {import('typescript').JSDoc|undefined} ast + * @param {import('typescript').JSDoc|import('typescript').JSDocTag|undefined} ast * @param {string} message * @return {{description: string, examples: Record}} */ @@ -67,7 +67,7 @@ function computeDescription(ast, message) { throw Error(`Missing description comment for message "${message}"`); } - if (ast.tags) { + if ('tags' in ast && ast.tags) { // This is a complex description with description and examples. let description = ''; /** @type {Record} */ @@ -520,7 +520,6 @@ function parseUIStrings(sourceStr, liveUIStrings) { // Use live message to avoid having to e.g. concat strings broken into parts. const message = (liveUIStrings[key]); - // @ts-expect-error - Not part of the public tsc interface yet. const jsDocComments = tsc.getJSDocCommentsAndTags(property); const {description, examples} = computeDescription(jsDocComments[0], message); diff --git a/core/test/gather/driver/network-monitor-test.js b/core/test/gather/driver/network-monitor-test.js index faa66ca424ff..73f6dabcdb6c 100644 --- a/core/test/gather/driver/network-monitor-test.js +++ b/core/test/gather/driver/network-monitor-test.js @@ -79,6 +79,7 @@ describe('NetworkMonitor', () => { ]); // Bring the starting events forward in the log. + /** @type {LH.Protocol.RawEventMessage[]} */ const startEvents = log.filter(m => m.method === 'Network.requestWillBeSent'); const restEvents = log.filter(m => !startEvents.includes(m)); return [...startEvents, ...restEvents]; diff --git a/core/test/scripts/i18n/collect-strings-test.js b/core/test/scripts/i18n/collect-strings-test.js index 71f62cf81460..0b70d0ddd5a0 100644 --- a/core/test/scripts/i18n/collect-strings-test.js +++ b/core/test/scripts/i18n/collect-strings-test.js @@ -293,7 +293,7 @@ describe('parseUIStrings', () => { */ exampleString: 'Hello World {variable}', /** - * A description without an @tag and + * A description without an tag and * across multiple lines. */ exampleString2: 'Just a plain string', @@ -317,7 +317,7 @@ describe('parseUIStrings', () => { }, exampleString2: { message: 'Just a plain string', - description: 'A description without an @tag and across multiple lines.', + description: 'A description without an tag and across multiple lines.', examples: {}, }, exampleString3: { diff --git a/package.json b/package.json index 51e57e75424b..88753ace07cc 100644 --- a/package.json +++ b/package.json @@ -175,8 +175,8 @@ "tabulator-tables": "^4.9.3", "terser": "^5.18.2", "testdouble": "^3.18.0", - "typed-query-selector": "^2.6.1", - "typescript": "^5.0.4", + "typed-query-selector": "^2.11.2", + "typescript": "5.5.3", "wait-for-expect": "^3.0.2", "webtreemap-cdt": "^3.2.1" }, diff --git a/report/renderer/drop-down-menu.js b/report/renderer/drop-down-menu.js index 5f7b65b31178..eac681973f90 100644 --- a/report/renderer/drop-down-menu.js +++ b/report/renderer/drop-down-menu.js @@ -168,23 +168,21 @@ export class DropDownMenu { * @return {HTMLElement} */ _getNextSelectableNode(allNodes, startNode) { - const nodes = allNodes.filter(/** @return {node is HTMLElement} */ (node) => { - if (!(node instanceof HTMLElement)) { - return false; - } - - // 'Save as Gist' option may be disabled. - if (node.hasAttribute('disabled')) { - return false; - } - - // 'Save as Gist' option may have display none. - if (window.getComputedStyle(node).display === 'none') { - return false; - } - - return true; - }); + const nodes = allNodes + .filter(node => node instanceof HTMLElement) + .filter(node => { + // 'Save as Gist' option may be disabled. + if (node.hasAttribute('disabled')) { + return false; + } + + // 'Save as Gist' option may have display none. + if (window.getComputedStyle(node).display === 'none') { + return false; + } + + return true; + }); let nextIndex = startNode ? (nodes.indexOf(startNode) + 1) : 0; if (nextIndex >= nodes.length) { diff --git a/report/types/augment-dom.d.ts b/report/types/augment-dom.d.ts index a57783b440a9..125673d4915a 100644 --- a/report/types/augment-dom.d.ts +++ b/report/types/augment-dom.d.ts @@ -11,14 +11,3 @@ // Import to augment querySelector/querySelectorAll with stricter type checking. import '../../types/internal/query-selector'; - -declare global { - var CompressionStream: { - prototype: CompressionStream, - new (format: string): CompressionStream, - }; - - interface CompressionStream extends GenericTransformStream { - readonly format: string; - } -} diff --git a/tsconfig.json b/tsconfig.json index 2566e5a6b85d..2a23a690ff83 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,6 +29,7 @@ ], "exclude": [ "build/test/*test-case*.js", + "build/process-global.js", "core/test/audits/**/*.js", "core/test/fixtures/**/*.js", "core/test/computed/**/*.js", diff --git a/types/internal/node.d.ts b/types/internal/node.d.ts index bd97d277fe41..71bd04f7b393 100644 --- a/types/internal/node.d.ts +++ b/types/internal/node.d.ts @@ -8,12 +8,6 @@ declare global { var isDevtools: boolean | undefined; var isLightrider: boolean | undefined; - // Augment Intl to include - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales - namespace Intl { - var getCanonicalLocales: (locales?: string | Array) => Array; - } - // Some functions defined in node are stringified and run in the browser. // Ensure those functions are working with the correct browser environment. interface Window { diff --git a/types/internal/query-selector.d.ts b/types/internal/query-selector.d.ts index fe8d30e37e37..86edebec8a2a 100644 --- a/types/internal/query-selector.d.ts +++ b/types/internal/query-selector.d.ts @@ -23,8 +23,8 @@ type HtmlAndSvgElementTagNameMap = MergeTypes = ParseSelectorToTagNames extends infer TagNames ? - TagNames extends Array ? - HtmlAndSvgElementTagNameMap[TagNames[number]] : + TagNames extends string ? + HtmlAndSvgElementTagNameMap[TagNames] : Element: // Fall back for queries typed-query-selector fails to parse, e.g. `'[alt], [aria-label]'`. never; diff --git a/yarn.lock b/yarn.lock index 615fd1ff34f6..9d820811f268 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1489,9 +1489,11 @@ integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA== "@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0": - version "16.18.11" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.11.tgz#cbb15c12ca7c16c85a72b6bdc4d4b01151bb3cae" - integrity sha512-3oJbGBUWuS6ahSnEq1eN2XrCyf4YsWI8OyCvo7c64zQJNplk3mO84t53o8lfTk+2ji59g5ycfc6qQ3fdHliHuA== + version "18.19.39" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.39.tgz#c316340a5b4adca3aee9dcbf05de385978590593" + integrity sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ== + dependencies: + undici-types "~5.26.4" "@types/node@^11.10.4": version "11.15.54" @@ -7167,10 +7169,10 @@ type-fest@^0.8.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== -typed-query-selector@^2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/typed-query-selector/-/typed-query-selector-2.6.1.tgz#73b6f591974129669df59d90f0bec4216e68a434" - integrity sha512-nzzcDrI0nncM5XTNyqeG7MrcXTx8lelUtNlTP+NvpnOfRzApyr+ZW4H/FoOaPfzmjn++Tf0ZxXpBN7Q3FN3ERw== +typed-query-selector@^2.11.2: + version "2.11.2" + resolved "https://registry.yarnpkg.com/typed-query-selector/-/typed-query-selector-2.11.2.tgz#30f9a2d7d51fc08781b277dff91c61aa8dd756c3" + integrity sha512-6rZP+cG3wPg2w1Zqv2VCOsSqlkGElrLSGeEkyrIU9mHG+JfQZE/6lE3oyQouz42sTS9n8fQXvwQBaVWz6dzpfQ== typedarray-to-buffer@^3.1.5: version "3.1.5" @@ -7179,10 +7181,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@^5.0.4: - version "5.0.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" - integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== +typescript@5.5.3: + version "5.5.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.3.tgz#e1b0a3c394190838a0b168e771b0ad56a0af0faa" + integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ== uglify-js@^3.1.4: version "3.14.4" @@ -7207,6 +7209,11 @@ unbzip2-stream@1.4.3: buffer "^5.2.1" through "^2.3.8" +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + union-value@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847"