Skip to content

fix(types): replace any with unknown for response in broker-protection types.js#2376

Open
jonathanKingston wants to merge 18 commits into
mainfrom
claude/fix-any-type-patch-24-sqf19
Open

fix(types): replace any with unknown for response in broker-protection types.js#2376
jonathanKingston wants to merge 18 commits into
mainfrom
claude/fix-any-type-patch-24-sqf19

Conversation

@jonathanKingston
Copy link
Copy Markdown
Contributor

@jonathanKingston jonathanKingston commented Feb 28, 2026

Asana Task/Github Issue:

Description

Testing Steps

Checklist

Please tick all that apply:

  • I have tested this change locally
  • I have tested this change locally in all supported browsers
  • This change will be visible to users
  • I have added automated tests that cover this change
  • I have ensured the change is gated by config
  • This change was covered by a ship review
  • This change was covered by a tech design
  • Any dependent config has been merged

https://claude.ai/code/session_01QaZ2NFE7y5u8YdZhjoc79m


Note

Low Risk
Type-only JSDoc changes that tighten SuccessResponse typing from any to 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 SuccessResponse generic (SuccessResponse<T>) and changing SuccessResponseInterface.response from any to a typed T (defaulting to unknown).

Updates JSDoc return types in build-url and getSupportingCodeToInject to specify concrete SuccessResponse payload 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.

@jonathanKingston jonathanKingston requested review from a team as code owners February 28, 2026 02:16
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 28, 2026

[Beta] Generated file diff

Time updated: Fri, 22 May 2026 10:15:47 GMT

Android
    - android/autofillImport.js
  • android/brokerProtection.js

File has changed

Apple
    - apple/contentScopeIsolated.js

File has changed

Integration
    - integration/contentScope.js

File has changed

Windows
    - windows/contentScope.js

File has changed

@jonathanKingston
Copy link
Copy Markdown
Contributor Author

@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.
Error: injected/src/features/broker-protection/actions/navigate.js(27,9): error TS2698: Spread types may only be created from object types.
Error: Process completed with exit code 2.

daxtheduck
daxtheduck previously approved these changes Feb 28, 2026
@daxtheduck daxtheduck dismissed their stale review February 28, 2026 09:56

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Feb 28, 2026
@daxtheduck daxtheduck dismissed their stale review February 28, 2026 11:31

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Feb 28, 2026
@daxtheduck daxtheduck dismissed their stale review March 1, 2026 22:57

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Mar 1, 2026
@daxtheduck daxtheduck dismissed their stale review March 2, 2026 00:09

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Mar 2, 2026
@jonathanKingston
Copy link
Copy Markdown
Contributor Author

@cursor can you checkout the test fail

@cursor
Copy link
Copy Markdown
Contributor

cursor Bot commented Mar 2, 2026

Fixed. The TS2698 errors in navigate.js were caused by spreading unknown-typed .success.response values after the anyunknown change. Added inline JSDoc casts to Record<string, unknown> at both spread sites — safe because buildUrl returns { url: string } and getSupportingCodeToInject returns {} or { code: string }.

  • tsc: clean
  • lint: clean
  • unit tests: all passing

Open in Web Open in Cursor 

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>
@daxtheduck daxtheduck dismissed their stale review March 2, 2026 12:06

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 2, 2026

Build Branch

Branch pr-releases/claude/fix-any-type-patch-24-sqf19
Commit a136246170
Updated May 22, 2026 at 10:15:20 AM UTC

Static preview entry points

QR codes (mobile preview)
Entry point QR code
Docs QR for docs preview
Static pages QR for static pages preview
Integration pages QR for integration pages preview

Integration commands

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#pr-releases/claude/fix-any-type-patch-24-sqf19

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-sqf19
Pin to exact commit

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#a1362461705db8d2d3f53a38769a635fc33760bf

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

daxtheduck
daxtheduck previously approved these changes Mar 2, 2026
@daxtheduck daxtheduck dismissed their stale review March 2, 2026 12:16

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Mar 2, 2026
@daxtheduck daxtheduck dismissed their stale review March 3, 2026 10:21

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

@daxtheduck daxtheduck dismissed their stale review March 3, 2026 11:51

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Mar 3, 2026
@daxtheduck daxtheduck dismissed their stale review March 3, 2026 12:18

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Mar 3, 2026
@daxtheduck daxtheduck dismissed their stale review March 3, 2026 15:05

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Mar 3, 2026
@daxtheduck daxtheduck dismissed their stale review March 4, 2026 14:10

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

@github-actions github-actions Bot added the patch Increment the patch version when merged label Mar 4, 2026
daxtheduck
daxtheduck previously approved these changes Mar 4, 2026
@daxtheduck daxtheduck dismissed their stale review March 5, 2026 00:09

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

@github-actions github-actions Bot added the semver-patch Bug fix / internal — no release needed label Mar 5, 2026
daxtheduck
daxtheduck previously approved these changes Mar 5, 2026
@daxtheduck daxtheduck dismissed their stale review March 5, 2026 00:31

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Mar 5, 2026
@daxtheduck daxtheduck dismissed their stale review March 5, 2026 00:58

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Mar 5, 2026
@daxtheduck daxtheduck dismissed their stale review March 9, 2026 22:43

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Web Compatibility Assessment

  • injected/src/features/broker-protection/types.js (134-163) — info: Change is JSDoc-only (SuccessResponse made generic with T=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 to SuccessResponse<{url: string}> | ErrorResponse in 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 to SuccessResponse<{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

  1. Add a focused type-check assertion test (or @ts-check fixture) that verifies SuccessResponse.create(...) preserves payload typing for {url: string} and {code?: string | null} to prevent future regression to overly broad any.
  2. Optional alternative: define named payload typedefs (e.g., BuildUrlResponsePayload, CaptchaSupportCodePayload) in broker-protection/types.js and reference them from action modules to avoid repeating inline object types and keep contracts centralized.
  3. Keep an eye on downstream call sites that previously depended on permissive any; stricter unknown may expose latent typing gaps during static checks (expected and desirable, but worth validating in CI type-check output).

Open in Web View Automation 

daxtheduck
daxtheduck previously approved these changes Mar 9, 2026
@daxtheduck daxtheduck dismissed their stale review May 22, 2026 10:16

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged semver-patch Bug fix / internal — no release needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants