From 4c9ce2d5373ceb32f1378733c050b24d359c00b2 Mon Sep 17 00:00:00 2001 From: Charis Kyriakou Date: Mon, 25 Sep 2023 09:48:57 +0000 Subject: [PATCH] Don't use 'as any' when checking open view --- .../src/model-editor/model-editor-view.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/extensions/ql-vscode/src/model-editor/model-editor-view.ts b/extensions/ql-vscode/src/model-editor/model-editor-view.ts index 50ea31d1d..6c6f9551c 100644 --- a/extensions/ql-vscode/src/model-editor/model-editor-view.ts +++ b/extensions/ql-vscode/src/model-editor/model-editor-view.ts @@ -1,4 +1,10 @@ -import { CancellationTokenSource, Uri, ViewColumn, window } from "vscode"; +import { + CancellationTokenSource, + TabInputWebview, + Uri, + ViewColumn, + window, +} from "vscode"; import { AbstractWebview, WebviewPanelConfig, @@ -151,7 +157,9 @@ export class ModelEditorView extends AbstractWebview< private isAModelEditorOpen(): boolean { return window.tabGroups.all.some((tabGroup) => tabGroup.tabs.some((tab) => { - const viewType: string | undefined = (tab.input as any)?.viewType; + const viewType = + tab.input instanceof TabInputWebview ? tab.input.viewType : undefined; + // The viewType has a prefix, such as "mainThreadWebview-", but if the // suffix matches that should be enough to identify the view. return viewType && viewType.endsWith("model-editor"); @@ -162,7 +170,9 @@ export class ModelEditorView extends AbstractWebview< private isAModelEditorActive(): boolean { return window.tabGroups.all.some((tabGroup) => tabGroup.tabs.some((tab) => { - const viewType: string | undefined = (tab.input as any)?.viewType; + const viewType = + tab.input instanceof TabInputWebview ? tab.input.viewType : undefined; + // The viewType has a prefix, such as "mainThreadWebview-", but if the // suffix matches that should be enough to identify the view. return viewType && viewType.endsWith("model-editor") && tab.isActive;