Repository navigation
Reject calls on values typed as any - #2656
Merged
Merged
Conversation
Layer: 1-no-unsafe-call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Calling a value typed
anyskips every type check, so a typo or a changed library API only shows up as "is not a function" at runtime. This enablestypescript/no-unsafe-callaterrorand 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 onanythat 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
@monaco-editor/reacttypesMonacofrom a pathmonaco-editorno longer exports, so it didn't resolve.CodeEditor.tsxnow uses a localtype Monaco = typeof MonacoEditor.express.d.tsaugmentedexpress-serve-static-core, which this package can't resolve, so the augmentation never took effect andreq.app.locals.loggerwasany. It's now a globalExpress.Localsaugmentation, so the logger isAppLogger. I droppedenv, since nothing sets it.cytoscape-canvasshim is typed ascytoscape.Ext, and tap event targets get cytoscape types instead ofanyand casts.trigger("doubleTap", event)becomestrigger("doubleTap", [event])to match the typed signature. Cytoscape's emitter already wraps a single argument in an array, so listeners get the same arguments.Open choice
The global
Express.Localsaugmentation also typesres.locals.logger, which is never set. No code readsres.localstoday. The alternative is to deleteexpress.d.tsand annotate the threereq.app.locals.loggerreads asAppLogger, asgetLogger()inapp.tsalready does. I went with the augmentation.Evidence
Before:
vp lintwith the rule on reported 29no-unsafe-callerrors in 9 files.After: no
no-unsafe-callerrors.vp checkpasses, andvp testpasses 4110 of 4110 (agent-tested).Verified live: agent-tested only:
anyvalue in the app, a test file, and the proxy server each raisedno-unsafe-callinvp lintandvp check.triggerforms, on a node and on the core.req.app.locals.loggerisAppLogger, notany.Merge Danger
Door: two-way
Impact: none
Type and lint config only, plus the one equivalent
triggercall. A revert has no data or config impact.Related
🤖 Written by an AI agent on my behalf.