chore: improve types by reducing the any type usage and type casting#2771
Conversation
|
c3d2fa5 to
403a80e
Compare
|
📦 A new experimental 🧪 version v0.0.0-snapshot.1777011056 of Redocly CLI has been published for testing. Install with NPM: npm install @redocly/cli@0.0.0-snapshot.1777011056
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1777011056
# or
npm install @redocly/respect-core@0.0.0-snapshot.1777011056 |
|
|
|
||
| const segments = pointer; | ||
| for (const segment of segments) { | ||
| if (typeof target !== 'object') { |
There was a problem hiding this comment.
Replaced the guard with explicit Array/Object detection.
| resolvedRef = await followRef(targetDoc, target, pushRef(refStack, target)); | ||
| targetDoc = resolvedRef.document || targetDoc; | ||
|
|
||
| if (typeof resolvedRef.node !== 'object') { |
There was a problem hiding this comment.
Moved to the else block below.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 403a80e. Configure here.
403a80e to
db4207a
Compare
db4207a to
7e65ed0
Compare

What/Why/How?
Improved typing by reducing the
anytype usage and type castingTesting
Pipeline and E2E passed.
Check yourself
Security
Note
Medium Risk
Mostly type-safety improvements, but
resolve.tschanges the$refpointer-walk logic (object/array handling and anchor collection timing), which could affect resolution behavior across bundling/linting.Overview
Reduces
anyusage across core utilities/rules by switching tounknown, tightening option/return types, and removing several casts (e.g., JSON formatter output, filter helpers, env/platform check, AJV error formatting, stats visitors).Hardens reference resolution in
resolve.tsby treating traversed nodes asunknown, guarding walks withisPlainObject/Array.isArray, and correctly following JSON Pointer segments through both objects and arrays (including when encountering nested$refs). It also adjusts when$anchorentries are collected and tightens rule exports/casts in the OAS2/OAS3 rule registries.Reviewed by Cursor Bugbot for commit 7e65ed0. Bugbot is set up for automated code reviews on this repo. Configure here.