Skip to content

fix(cli): use ReturnType<typeof setTimeout> for timer map#789

Closed
chenrui333 wants to merge 1 commit into
fedify-dev:mainfrom
chenrui333:fix/settimeout-type-annotation
Closed

fix(cli): use ReturnType<typeof setTimeout> for timer map#789
chenrui333 wants to merge 1 commit into
fedify-dev:mainfrom
chenrui333:fix/settimeout-type-annotation

Conversation

@chenrui333
Copy link
Copy Markdown
Contributor

@chenrui333 chenrui333 commented Jun 5, 2026

Summary

Deno 2.8+ / TypeScript 6.0 changed setTimeout's return type from number to Timeout, causing TS2345 when storing timer IDs in the signalTimers WeakMap.

Fix

Use ReturnType<typeof setTimeout> which is compatible across all TypeScript/Deno versions.

TS2345 [ERROR]: Argument of type 'Timeout' is not assignable to parameter of type 'number'.
  signalTimers.set(controller.signal, timerId);
                                      ~~~~~~~
    at packages/cli/src/lookup.ts:498:39

Deno 2.8+ / TypeScript 6.0 changed setTimeout's return type from
number to Timeout, causing TS2345 when storing timer IDs in the
WeakMap. Use ReturnType<typeof setTimeout> for cross-version compat.

Signed-off-by: Rui Chen <rui@chenrui.dev>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the type of the values in the signalTimers WeakMap in packages/cli/src/lookup.ts from number to ReturnType to improve cross-platform compatibility. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f721b62f-7f93-45a1-8c35-8a0325e86bbc

📥 Commits

Reviewing files that changed from the base of the PR and between 0f808ac and fc77c00.

📒 Files selected for processing (1)
  • packages/cli/src/lookup.ts

📝 Walkthrough

Walkthrough

The PR corrects the type annotation for the signalTimers WeakMap in the lookup module, changing its value type from number to ReturnType<typeof setTimeout>. This aligns the stored timer handles with the actual return type of setTimeout in the runtime environment, improving type safety without changing behavior.

Changes

Signal Timer Type Correction

Layer / File(s) Summary
Timer type alignment
packages/cli/src/lookup.ts
The signalTimers WeakMap value type is updated from number to ReturnType<typeof setTimeout>, matching the actual type of handles returned by setTimeout and expected by timeout signal management functions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: updating the timer map's type to use ReturnType to fix compatibility issues with Deno 2.8+ and TypeScript 6.0.
Description check ✅ Passed The description clearly explains the context (TypeScript/Deno version changes), the problem (type mismatch error), and the solution (using ReturnType), directly relating to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dahlia
Copy link
Copy Markdown
Member

dahlia commented Jun 5, 2026

Thanks for your contribution! Since it should be fixed in 2.2.x versions too, I will cherry-pick your commit instead of merging it.

@dahlia dahlia self-assigned this Jun 5, 2026
@dahlia dahlia added the activitypub/bridgy-fed Bridgy Fed compatibility label Jun 5, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
packages/cli/src/lookup.ts 71.77% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

dahlia added a commit that referenced this pull request Jun 5, 2026
The fix uses ReturnType<typeof setTimeout> for the signalTimers
WeakMap in @fedify/cli, which is compatible across Deno 2.8+ /
TypeScript 6.0 where setTimeout returns Timeout instead of number.

#789
@dahlia
Copy link
Copy Markdown
Member

dahlia commented Jun 5, 2026

Fixed in v2.0.20, v2.1.16, and v2.2.5.

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

Labels

activitypub/bridgy-fed Bridgy Fed compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants