[deps] Upgrade TypeScript to 5.6.2
This upgrade requries some changes to the code base. TS 5.6 made the
types for the iterator protocol more strict. We have some places in the
code base where we retrieve the first item of `Set` via the `values()`
iterator. This CL adds 'as' casts or uses 'done' as appropriate. For
test code we use '!'.
[email protected]
Bug: None
Change-Id: I09f1dccb31485a7e3036870f7688aa57f1202018
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5920100
Reviewed-by: Alex Rudenko <[email protected]>
Commit-Queue: Simon Zünd <[email protected]>
diff --git a/front_end/panels/animation/AnimationModel.ts b/front_end/panels/animation/AnimationModel.ts
index 6474f30..7eae485 100644
--- a/front_end/panels/animation/AnimationModel.ts
+++ b/front_end/panels/animation/AnimationModel.ts
@@ -147,7 +147,7 @@
private createGroupFromPendingAnimations(): AnimationGroup {
console.assert(this.#pendingAnimations.size > 0);
- const firstAnimationId = this.#pendingAnimations.values().next().value;
+ const firstAnimationId = this.#pendingAnimations.values().next().value as string;
this.#pendingAnimations.delete(firstAnimationId);
const firstAnimation = this.#animationsById.get(firstAnimationId);
diff --git a/front_end/panels/elements/ElementsPanel.ts b/front_end/panels/elements/ElementsPanel.ts
index 5b6bb5f..83ee345 100644
--- a/front_end/panels/elements/ElementsPanel.ts
+++ b/front_end/panels/elements/ElementsPanel.ts
@@ -461,10 +461,11 @@
}
override focus(): void {
- if (this.treeOutlines.size) {
- this.treeOutlines.values().next().value.focus();
- } else {
+ const firstTreeOutline = this.treeOutlines.values().next();
+ if (firstTreeOutline.done) {
this.domTreeContainer.focus();
+ } else {
+ firstTreeOutline.value.focus();
}
}
diff --git a/front_end/panels/issues/AttributionReportingIssueDetailsView.ts b/front_end/panels/issues/AttributionReportingIssueDetailsView.ts
index c759f9c..7d59b50 100644
--- a/front_end/panels/issues/AttributionReportingIssueDetailsView.ts
+++ b/front_end/panels/issues/AttributionReportingIssueDetailsView.ts
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import type * as Protocol from '../../generated/protocol.js';
import * as Host from '../../core/host/host.js';
import * as i18n from '../../core/i18n/i18n.js';
+import type * as Protocol from '../../generated/protocol.js';
import * as IssuesManager from '../../models/issues_manager/issues_manager.js';
import {AffectedItem, AffectedResourcesView} from './AffectedResourcesView.js';
@@ -43,10 +43,11 @@
override update(): void {
this.clear();
const issues = this.issue.getAttributionReportingIssues();
- if (issues.size > 0) {
- this.#appendDetails(issues.values().next().value.code(), issues);
- } else {
+ const issue = issues.values().next();
+ if (issue.done) {
this.updateAffectedResourceCount(0);
+ } else {
+ this.#appendDetails(issue.value.code(), issues);
}
}
diff --git a/front_end/panels/issues/CorsIssueDetailsView.ts b/front_end/panels/issues/CorsIssueDetailsView.ts
index fb155a5..b2b4e18 100644
--- a/front_end/panels/issues/CorsIssueDetailsView.ts
+++ b/front_end/panels/issues/CorsIssueDetailsView.ts
@@ -10,7 +10,6 @@
import * as NetworkForward from '../../panels/network/forward/forward.js';
import {AffectedItem, AffectedResourcesView} from './AffectedResourcesView.js';
-
import {type AggregatedIssue} from './IssueAggregator.js';
import {type IssueView} from './IssueView.js';
@@ -489,10 +488,11 @@
update(): void {
this.clear();
const issues = this.issue.getCorsIssues();
- if (issues.size > 0) {
- this.#appendDetails(issues.values().next().value.code(), issues);
- } else {
+ const issue = issues.values().next();
+ if (issue.done) {
this.updateAffectedResourceCount(0);
+ } else {
+ this.#appendDetails(issue.value.code(), issues);
}
}
}
diff --git a/front_end/panels/issues/GenericIssueDetailsView.ts b/front_end/panels/issues/GenericIssueDetailsView.ts
index 6a52ad9..cef7789 100644
--- a/front_end/panels/issues/GenericIssueDetailsView.ts
+++ b/front_end/panels/issues/GenericIssueDetailsView.ts
@@ -4,8 +4,8 @@
import * as i18n from '../../core/i18n/i18n.js';
import type * as Platform from '../../core/platform/platform.js';
-import type * as IssuesManager from '../../models/issues_manager/issues_manager.js';
import * as Protocol from '../../generated/protocol.js';
+import type * as IssuesManager from '../../models/issues_manager/issues_manager.js';
import {AffectedResourcesView} from './AffectedResourcesView.js';
@@ -35,8 +35,8 @@
#appendDetails(genericIssues: ReadonlySet<IssuesManager.GenericIssue.GenericIssue>): void {
const header = document.createElement('tr');
- const sampleIssueDetails = genericIssues.values().next().value.details();
- if (sampleIssueDetails.frameId) {
+ const sampleIssueDetails = genericIssues.values().next().value?.details();
+ if (sampleIssueDetails?.frameId) {
this.appendColumnTitle(header, i18nString(UIStrings.frameId));
}
diff --git a/front_end/panels/network/NetworkLogView.ts b/front_end/panels/network/NetworkLogView.ts
index 50a1834..a130857 100644
--- a/front_end/panels/network/NetworkLogView.ts
+++ b/front_end/panels/network/NetworkLogView.ts
@@ -1491,7 +1491,7 @@
// While creating nodes it may add more entries into staleRequests because redirect request nodes update the parent
// node so we loop until we have no more stale requests.
while (this.staleRequests.size) {
- const request = this.staleRequests.values().next().value;
+ const request = this.staleRequests.values().next().value as SDK.NetworkRequest.NetworkRequest;
this.staleRequests.delete(request);
let node = networkRequestToNode.get(request);
if (!node) {
diff --git a/front_end/panels/profiler/ProfileLauncherView.ts b/front_end/panels/profiler/ProfileLauncherView.ts
index c11d529..b4ddab5 100644
--- a/front_end/panels/profiler/ProfileLauncherView.ts
+++ b/front_end/panels/profiler/ProfileLauncherView.ts
@@ -195,7 +195,7 @@
restoreSelectedProfileType(): void {
let typeId = this.selectedProfileTypeSetting.get();
if (!this.typeIdToOptionElementAndProfileType.has(typeId)) {
- typeId = this.typeIdToOptionElementAndProfileType.keys().next().value;
+ typeId = this.typeIdToOptionElementAndProfileType.keys().next().value as string;
this.selectedProfileTypeSetting.set(typeId);
}
diff --git a/front_end/panels/protocol_monitor/ProtocolMonitor.ts b/front_end/panels/protocol_monitor/ProtocolMonitor.ts
index f42d3f6..fab28e9 100644
--- a/front_end/panels/protocol_monitor/ProtocolMonitor.ts
+++ b/front_end/panels/protocol_monitor/ProtocolMonitor.ts
@@ -716,7 +716,7 @@
}
this.#commandHistory.add(value);
if (this.#commandHistory.size > this.#maxHistorySize) {
- const earliestEntry = this.#commandHistory.values().next().value;
+ const earliestEntry = this.#commandHistory.values().next().value as string;
this.#commandHistory.delete(earliestEntry);
}
}
diff --git a/front_end/panels/sources/DebuggerPlugin.ts b/front_end/panels/sources/DebuggerPlugin.ts
index 25fc003..25a9e80 100644
--- a/front_end/panels/sources/DebuggerPlugin.ts
+++ b/front_end/panels/sources/DebuggerPlugin.ts
@@ -585,7 +585,7 @@
!Bindings.IgnoreListManager.IgnoreListManager.instance().isUserIgnoreListedURL(this.uiSourceCode.url())) {
if (this.scriptFileForDebuggerModel.size) {
const scriptFile: Bindings.ResourceScriptMapping.ResourceScriptFile =
- this.scriptFileForDebuggerModel.values().next().value;
+ this.scriptFileForDebuggerModel.values().next().value as Bindings.ResourceScriptMapping.ResourceScriptFile;
const addSourceMapURLLabel = i18nString(UIStrings.addSourceMap);
contextMenu.debugSection().appendItem(
addSourceMapURLLabel, addSourceMapURL.bind(null, scriptFile), {jslogContext: 'add-source-map'});
diff --git a/front_end/panels/timeline/TimelineTreeView.test.ts b/front_end/panels/timeline/TimelineTreeView.test.ts
index 794dcd1..75df69d 100644
--- a/front_end/panels/timeline/TimelineTreeView.test.ts
+++ b/front_end/panels/timeline/TimelineTreeView.test.ts
@@ -160,15 +160,15 @@
const tree = callTreeView.buildTree();
const treeEntries = tree.children().entries();
const groupEntry = treeEntries.next();
- const nodeName = groupEntry.value[0];
- const node = groupEntry.value[1];
+ const nodeName = groupEntry.value![0];
+ const node = groupEntry.value![1];
assert.strictEqual(nodeName, 'scripting');
assert.strictEqual(callTreeView.displayInfoForGroupNode(node).color, 'rgb(250 204 21 / 100%)');
assert.isTrue(node.isGroupNode());
const children = node.children().values();
- assert.strictEqual(children.next().value.event.name, 'first console time');
- assert.strictEqual(children.next().value.event.name, 'third console time');
+ assert.strictEqual(children.next().value!.event!.name, 'first console time');
+ assert.strictEqual(children.next().value!.event!.name, 'third console time');
});
it('groups events by category in the Bottom up Tree view', async function() {
const {parsedTrace} = await TraceLoader.traceEngine(this, 'sync-like-timings.json.gz');
@@ -182,16 +182,16 @@
const tree = callTreeView.buildTree();
const treeEntries = tree.children().entries();
const groupEntry = treeEntries.next();
- const nodeName = groupEntry.value[0];
- const node = groupEntry.value[1];
+ const nodeName = groupEntry.value![0];
+ const node = groupEntry.value![1];
assert.strictEqual(nodeName, 'scripting');
assert.strictEqual(callTreeView.displayInfoForGroupNode(node).color, 'rgb(250 204 21 / 100%)');
assert.isTrue(node.isGroupNode());
const children = node.children().values();
- assert.strictEqual(children.next().value.event.name, 'second console time');
- assert.strictEqual(children.next().value.event.name, 'first console time');
- assert.strictEqual(children.next().value.event.name, 'third console time');
+ assert.strictEqual(children.next().value!.event!.name, 'second console time');
+ assert.strictEqual(children.next().value!.event!.name, 'first console time');
+ assert.strictEqual(children.next().value!.event!.name, 'third console time');
});
it('can group entries by domain', async function() {
diff --git a/front_end/panels/timeline/overlays/OverlaysImpl.ts b/front_end/panels/timeline/overlays/OverlaysImpl.ts
index a097473..74f27a6 100644
--- a/front_end/panels/timeline/overlays/OverlaysImpl.ts
+++ b/front_end/panels/timeline/overlays/OverlaysImpl.ts
@@ -1051,7 +1051,7 @@
}
// The event is off the bottom of the network chart. In this case return the bottom of the network chart.
- if (y > this.#dimensions.charts.network.heightPixels ?? 0) {
+ if (y > this.#dimensions.charts.network.heightPixels) {
return this.#dimensions.charts.network.heightPixels;
}
}
@@ -1588,7 +1588,7 @@
return false;
}
- if (y > this.#dimensions.charts.network.heightPixels ?? 0) {
+ if (y > this.#dimensions.charts.network.heightPixels) {
// The event is off the bottom of the network chart.
return false;
}