Skip to content

Commit

Permalink
deps: upgrade typescript to 5.5.3 (#16091)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Jul 3, 2024
1 parent e0cdc93 commit a21fde7
Show file tree
Hide file tree
Showing 21 changed files with 65 additions and 85 deletions.
2 changes: 1 addition & 1 deletion cli/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions cli/sentry-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -47,7 +47,7 @@ function prompt() {

return Promise.race([
prompt.run().then(result => {
clearTimeout(/** @type {NodeJS.Timer} */ (timeout));
clearTimeout(timeout);
return result;
}),
timeoutPromise,
Expand Down
3 changes: 1 addition & 2 deletions core/computed/critical-request-chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion core/gather/driver/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions core/gather/driver/wait-for-condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -225,7 +225,7 @@ function waitForCPUIdle(session, waitForCPUQuiet) {
};
}

/** @type {NodeJS.Timer|undefined} */
/** @type {NodeJS.Timeout|undefined} */
let lastTimeout;
let canceled = false;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
17 changes: 5 additions & 12 deletions core/gather/gatherers/link-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/gather/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions core/lib/cdt/generated/ParsedURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -67,7 +68,6 @@ function normalizePath(path) {
}
return normalizedPath;
}
exports.normalizePath = normalizePath;
class ParsedURL {
isValid;
url;
Expand Down
6 changes: 3 additions & 3 deletions core/lib/cdt/generated/SourceMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -58,7 +59,6 @@ function parseSourceMap(content) {
}
return JSON.parse(content);
}
exports.parseSourceMap = parseSourceMap;
class SourceMapEntry {
lineNumber;
columnNumber;
Expand Down Expand Up @@ -470,7 +470,7 @@ exports.SourceMap = SourceMap;
}
}
SourceMap.StringCharIterator = StringCharIterator;
})(SourceMap = exports.SourceMap || (exports.SourceMap = {}));
})(SourceMap || (exports.SourceMap = SourceMap = {}));


module.exports = SourceMap;
Expand Down
4 changes: 2 additions & 2 deletions core/lib/tracehouse/cpu-profile-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down
1 change: 0 additions & 1 deletion core/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},` +
Expand Down
5 changes: 2 additions & 3 deletions core/scripts/i18n/collect-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>}}
*/
Expand All @@ -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<string, string>} */
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions core/test/gather/driver/network-monitor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions core/test/scripts/i18n/collect-strings-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
32 changes: 15 additions & 17 deletions report/renderer/drop-down-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 0 additions & 11 deletions report/types/augment-dom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 0 additions & 6 deletions types/internal/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>) => Array<string>;
}

// Some functions defined in node are stringified and run in the browser.
// Ensure those functions are working with the correct browser environment.
interface Window {
Expand Down
4 changes: 2 additions & 2 deletions types/internal/query-selector.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type HtmlAndSvgElementTagNameMap = MergeTypes<HTMLElementTagNameMap|SVGElementTa
[id: string]: Element;
};
type QuerySelectorParse<I extends string> = ParseSelectorToTagNames<I> extends infer TagNames ?
TagNames extends Array<string> ?
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;

Expand Down
29 changes: 18 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit a21fde7

Please sign in to comment.