Skip to content

Reject calls on values typed as any - #2656

Merged
kmcginnes merged 1 commit into
mainfrom
enable-no-unsafe-call-lint-rule
Nov 24, 2026
Merged

kmcginnes merged 1 commit into
mainfrom
enable-no-unsafe-call-lint-rule

Conversation

@kmcginnes

Copy link
Copy Markdown
Collaborator

Summary

Calling a value typed any skips every type check, so a typo or a changed library API only shows up as "is not a function" at runtime. This enables typescript/no-unsafe-call at error and fixes all 29 violations with real types: no disables, no overrides.

User-facing: none

Why this rule

This week's lint rule pick. The top three candidates by value and size:

  • typescript/no-unsafe-call, 29 violations in 9 files. Chosen: it catches calls on any that can throw at runtime, and it fits one small PR.
  • typescript/no-unsafe-return, 65 violations in 23 files.
  • typescript/no-unsafe-argument, 86 violations in 23 files.

Notable fixes

  • Code editor: @monaco-editor/react types Monaco from a path monaco-editor no longer exports, so it didn't resolve. CodeEditor.tsx now uses a local type Monaco = typeof MonacoEditor.
  • Proxy server: express.d.ts augmented express-serve-static-core, which this package can't resolve, so the augmentation never took effect and req.app.locals.logger was any. It's now a global Express.Locals augmentation, so the logger is AppLogger. I dropped env, since nothing sets it.
  • Graph: the cytoscape-canvas shim is typed as cytoscape.Ext, and tap event targets get cytoscape types instead of any and casts.
  • Double tap: trigger("doubleTap", event) becomes trigger("doubleTap", [event]) to match the typed signature. Cytoscape's emitter already wraps a single argument in an array, so listeners get the same arguments.
 // packages/graph-explorer-proxy-server/src/express.d.ts
-declare module "express-serve-static-core" {
-  interface Application {
-    locals: { env: EnvironmentValues; logger: AppLogger } & Record<string, unknown>;
-  }
-}
+declare global {
+  namespace Express {
+    interface Locals { logger: AppLogger }
+  }
+}

Open choice

The global Express.Locals augmentation also types res.locals.logger, which is never set. No code reads res.locals today. The alternative is to delete express.d.ts and annotate the three req.app.locals.logger reads as AppLogger, as getLogger() in app.ts already does. I went with the augmentation.

Evidence

Before: vp lint with the rule on reported 29 no-unsafe-call errors in 9 files.

After: no no-unsafe-call errors. vp check passes, and vp test passes 4110 of 4110 (agent-tested).

Verified live: agent-tested only:

  • Temporary files calling an any value in the app, a test file, and the proxy server each raised no-unsafe-call in vp lint and vp check.
  • A headless cytoscape 3.34.4 script gave identical listener arguments for both trigger forms, on a node and on the core.
  • A type probe showed req.app.locals.logger is AppLogger, not any.

Merge Danger

Door: two-way

Impact: none

Type and lint config only, plus the one equivalent trigger call. A revert has no data or config impact.

Related


🤖 Written by an AI agent on my behalf.

Layer: 1-no-unsafe-call

@kmcginnes kmcginnes left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@kmcginnes
kmcginnes merged commit 4197b44 into main Nov 24, 2026
4 checks passed
@kmcginnes
kmcginnes deleted the enable-no-unsafe-call-lint-rule branch November 24, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant