Skip to content

Commit 091406e

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
[cleanup] Clean up types in InspectorFrontendHost
Uses some better cast to reduce the needs of ignore error comments. Also fixes and eslint rule violation. Bug: none Change-Id: Ie43f6bfdef26bd58c5abcb5915a786bbefe8e7bc Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6797375 Reviewed-by: Danil Somsikov <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]> Commit-Queue: Danil Somsikov <[email protected]> Auto-Submit: Nikolay Vitkov <[email protected]>
1 parent ee36ae4 commit 091406e

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

front_end/core/host/InspectorFrontendHost.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31-
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration)
32-
/* eslint-disable @typescript-eslint/no-unused-vars */
33-
3431
import * as Common from '../common/common.js';
3532
import * as i18n from '../i18n/i18n.js';
3633
import * as Platform from '../platform/platform.js';
@@ -89,8 +86,14 @@ const OVERRIDES_FILE_SYSTEM_PATH = '/overrides' as Platform.DevToolsPath.RawPath
8986
*/
9087
export class InspectorFrontendHostStub implements InspectorFrontendHostAPI {
9188
readonly #urlsBeingSaved = new Map<Platform.DevToolsPath.RawPathString|Platform.DevToolsPath.UrlString, string[]>();
92-
events!: Common.EventTarget.EventTarget<EventTypes>;
9389
#fileSystem: FileSystem|null = null;
90+
/**
91+
* Injected bellow in both stub and normal runs via:
92+
* ```ts
93+
* InspectorFrontendHostInstance.events = new Common.ObjectWrapper.ObjectWrapper();
94+
* ```
95+
*/
96+
declare events: Common.EventTarget.EventTarget<EventTypes>;
9497

9598
recordedCountHistograms:
9699
Array<{histogramName: string, sample: number, min: number, exclusiveMax: number, bucketSize: number}> = [];
@@ -224,7 +227,7 @@ export class InspectorFrontendHostStub implements InspectorFrontendHostAPI {
224227
try {
225228
const trimmed = Platform.StringUtilities.trimURL(url);
226229
fileName = Platform.StringUtilities.removeURLFragment(trimmed);
227-
} catch (error) {
230+
} catch {
228231
// If url is not a valid URL, it is probably a filename.
229232
fileName = url;
230233
}
@@ -593,19 +596,15 @@ class InspectorFrontendAPIImpl {
593596
(function(): void {
594597

595598
function initializeInspectorFrontendHost(): void {
596-
let proto;
597599
if (!InspectorFrontendHostInstance) {
598600
// Instantiate stub for web-hosted mode if necessary.
599601
// @ts-expect-error Global injected by devtools_compatibility.js
600602
globalThis.InspectorFrontendHost = InspectorFrontendHostInstance = new InspectorFrontendHostStub();
601603
} else {
602604
// Otherwise add stubs for missing methods that are declared in the interface.
603-
proto = InspectorFrontendHostStub.prototype;
604-
for (const name of Object.getOwnPropertyNames(proto)) {
605-
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration)
606-
// @ts-expect-error
605+
const proto = InspectorFrontendHostStub.prototype;
606+
for (const name of (Object.getOwnPropertyNames(proto) as Array<keyof InspectorFrontendHostAPI>)) {
607607
const stub = proto[name];
608-
// @ts-expect-error Global injected by devtools_compatibility.js
609608
if (typeof stub !== 'function' || InspectorFrontendHostInstance[name]) {
610609
continue;
611610
}

0 commit comments

Comments
 (0)