fix(types): replace any with unknown for response in broker-protection types.js#2376
fix(types): replace any with unknown for response in broker-protection types.js#2376jonathanKingston wants to merge 18 commits into
Conversation
[Beta] Generated file diffTime updated: Fri, 22 May 2026 10:15:47 GMT Android
File has changed AppleFile has changed IntegrationFile has changed WindowsFile has changed |
|
@cursoragen fix pleaset rror: injected/src/features/broker-protection/actions/navigate.js(26,9): error TS2698: Spread types may only be created from object types. |
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
|
@cursor can you checkout the test fail |
|
Fixed. The TS2698 errors in
|
The change from any to unknown on SuccessResponseInterface.response caused TS2698 (spread types may only be created from object types) at lines 26-27 of navigate.js. Assert as Record<string, unknown> at the spread sites since both buildUrl and getSupportingCodeToInject always return object-typed responses. Co-authored-by: Jonathan Kingston <jonathanKingston@users.noreply.github.com>
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Build Branch
Static preview entry points
QR codes (mobile preview)
Integration commandsnpm (Android / Extension): Swift Package Manager (Apple): .package(url: "https://github.com/duckduckgo/content-scope-scripts.git", branch: "pr-releases/claude/fix-any-type-patch-24-sqf19")git submodule (Windows): git -C submodules/content-scope-scripts fetch origin pr-releases/claude/fix-any-type-patch-24-sqf19
git -C submodules/content-scope-scripts checkout origin/pr-releases/claude/fix-any-type-patch-24-sqf19Pin to exact commitnpm (Android / Extension): Swift Package Manager (Apple): .package(url: "https://github.com/duckduckgo/content-scope-scripts.git", revision: "a1362461705db8d2d3f53a38769a635fc33760bf")git submodule (Windows): git -C submodules/content-scope-scripts fetch origin pr-releases/claude/fix-any-type-patch-24-sqf19
git -C submodules/content-scope-scripts checkout a1362461705db8d2d3f53a38769a635fc33760bf |
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
There was a problem hiding this comment.
Web Compatibility Assessment
injected/src/features/broker-protection/types.js(134-163) — info: Change is JSDoc-only (SuccessResponsemade generic withT=unknown), with no constructor/static runtime behavior changes. No API shim/proxy/wrapper surface changes, so no impact on descriptor fidelity,toString()masking, prototype chains, or DOM timing paths.injected/src/features/broker-protection/actions/build-url.js(9) — info: Return type narrowed toSuccessResponse<{url: string}> | ErrorResponsein annotations only; function body and returned runtime object shape are unchanged.injected/src/features/broker-protection/captcha-services/captcha.service.js(31) — info: Return annotation narrowed toSuccessResponse<{code?: string | null}> | ErrorResponse; runtime behavior remains unchanged ({}for backward-compat path,{code: ...}for provider path).
No web-compat regression findings (warning/error) were identified in the changed lines.
Security Assessment
injected/src/features/broker-protection/types.js(134-163) — info: No trust-boundary/runtime changes. No new global reads, captures, messaging paths, bridge logic, origin checks, or dynamic execution introduced.injected/src/features/broker-protection/actions/build-url.js(9) — info: Type annotation-only change; no new URL/network/data-flow behavior.injected/src/features/broker-protection/captcha-services/captcha.service.js(31) — info: Type annotation-only change; no message transport, iframe, or exfiltration surface changes.
No security findings (error/critical) were identified in the changed lines.
Risk Level
Low Risk — The PR is type-surface/JSDoc tightening only, with unchanged runtime logic and no modifications to wrapper utilities, captured globals, messaging transports, or other security-sensitive execution paths.
Recommendations
- Add a focused type-check assertion test (or
@ts-checkfixture) that verifiesSuccessResponse.create(...)preserves payload typing for{url: string}and{code?: string | null}to prevent future regression to overly broadany. - Optional alternative: define named payload typedefs (e.g.,
BuildUrlResponsePayload,CaptchaSupportCodePayload) inbroker-protection/types.jsand reference them from action modules to avoid repeating inline object types and keep contracts centralized. - Keep an eye on downstream call sites that previously depended on permissive
any; stricterunknownmay expose latent typing gaps during static checks (expected and desirable, but worth validating in CI type-check output).
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.



Asana Task/Github Issue:
Description
Testing Steps
Checklist
Please tick all that apply:
https://claude.ai/code/session_01QaZ2NFE7y5u8YdZhjoc79m
Note
Low Risk
Type-only JSDoc changes that tighten
SuccessResponsetyping fromanyto generic/unknown, with no runtime logic changes. Low risk aside from potential downstream type-checking/IDE annotation adjustments.Overview
Improves broker-protection response typing by making
SuccessResponsegeneric (SuccessResponse<T>) and changingSuccessResponseInterface.responsefromanyto a typedT(defaulting tounknown).Updates JSDoc return types in
build-urlandgetSupportingCodeToInjectto specify concreteSuccessResponsepayload shapes (e.g.,{url: string}and{code?: string | null}), clarifying what callers can expect.Reviewed by Cursor Bugbot for commit 0837d39. Bugbot is set up for automated code reviews on this repo. Configure here.