A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
chore(frontend/lsp): Replace "as `any`" type assertion with a type guard (#5437)
Trevor Manz8c4735b9732e
diff --git a/frontend/src/core/codemirror/lsp/notebook-lsp.ts b/frontend/src/core/codemirror/lsp/notebook-lsp.tsindex 5644cbf22d..a9d279f39c 100644--- a/frontend/src/core/codemirror/lsp/notebook-lsp.ts+++ b/frontend/src/core/codemirror/lsp/notebook-lsp.ts@@ -8,7 +8,11 @@ import { Logger } from "@/utils/Logger";import { LRUCache } from "@/utils/lru";import { getTopologicalCodes } from "../copilot/getCodes";import { createNotebookLens } from "./lens";-import { CellDocumentUri, type ILanguageServerClient } from "./types";+import {+ CellDocumentUri,+ type ILanguageServerClient,+ isNotifyingClient,+} from "./types";import { getLSPDocument } from "./utils";export class NotebookLanguageServerClient implements ILanguageServerClient {@@ -42,12 +46,10 @@ export class NotebookLanguageServerClient implements ILanguageServerClient {// Handle configuration after initializationthis.initializePromise.then(() => {invariant(- "notify" in this.client,+ isNotifyingClient(this.client),"notify is not a method on the client",);-- // eslint-disable-next-line @typescript-eslint/no-explicit-any- (this.client as any).notify("workspace/didChangeConfiguration", {+ this.client.notify("workspace/didChangeConfiguration", {settings: initialSettings,});});diff --git a/frontend/src/core/codemirror/lsp/types.ts b/frontend/src/core/codemirror/lsp/types.tsindex 9f7e374b04..f4c46fc8f7 100644--- a/frontend/src/core/codemirror/lsp/types.ts+++ b/frontend/src/core/codemirror/lsp/types.ts@@ -25,3 +25,18 @@ export const CellDocumentUri = {return uri.slice(this.PREFIX.length) as CellId;},};++/**+ * Notify is a @protected method on `LanguageServerClient`,+ * hiding public use with TypeScript.+ */+export function isNotifyingClient(+ client: ILanguageServerClient,+): client is ILanguageServerClient & {+ notify: (+ kind: string,+ options: { settings: Record<string, unknown> },+ ) => void;+} {+ return "notify" in client;+}