Skip to content

fix(types): ship compiled .d.ts so app tsconfigs never check our sources - #698

Merged
sunnylqm merged 3 commits into
masterfrom
claude/react-native-update-types-1f7817
Oct 19, 2026
Merged

sunnylqm merged 3 commits into
masterfrom
claude/react-native-update-types-1f7817

Conversation

@sunnylqm

@sunnylqm sunnylqm commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

package.json types points at src/index.ts, so apps running tsc --noEmit type-check this package's TS sources under their own tsconfig and React Native version — skipLibCheck does not cover .ts sources. After upgrading to 10.62.0, apps on RN 0.88 with noUnusedLocals get:

  • src/client.ts:255 TS6133 — the private emitError delegate is never read.
  • src/clientDownload.ts:180 TS2349 — addListener called on the union of DeviceEventEmitter and the NativeEventEmitter; their signatures no longer unify under RN 0.88 types.

Fix

The two errors

  • Remove the unused private emitError delegate (private, unreachable from outside). Tests now call reporter.emitError directly.
  • Split the ternary into two separate addListener calls instead of calling on the union (no type assertion; runtime behavior unchanged).

The root cause: ship compiled declarations

  • tsconfig.build.json emits declarations only (tsc --emitDeclarationOnly, the repo's own TS, no new dependency) from src (minus __tests__) to lib/typescript.
  • package.json: types → lib/typescript/index.d.ts; files adds lib/typescript; new build:types script; prepack runs it after lint, so npm publish always ships fresh declarations. lib/ is gitignored and excluded from the lint tsc.
  • main stays src/index — Metro keeps bundling the TS sources exactly as before. Harmony (harmony/pushy.har, hvigor-plugin.ts) and codegen (codegenConfig.jsSrcsDir: src) are untouched.
  • CI: lint.yml and the publish action build the declarations before check-packlist.js, which now requires the file types names to be packed.

Impact on existing users

  • Apps' tsc now reads .d.ts files, so skipLibCheck applies and their noUnusedLocals / strict settings or RN type differences can no longer surface errors from inside this package.
  • The public types are the same (generated from the same sources); no API or runtime change.
  • Deep imports such as react-native-update/src/xxx still resolve to the TS sources (and are still checked by the app's tsc) — they were never public API.
  • Installing from git or a local link without running build:types: lib/typescript is absent and TypeScript falls back to main (src/index.ts), i.e. today's behavior.

Verification

  • Scratch app with react-native@0.88.0 + @react-native/typescript-config@0.88 + noUnusedLocals: HEAD reproduces both errors; the first commit reports none.
  • bun lint (incl. tsc --noEmit), bun test src/__tests__ (480 pass, 0 fail), bun build:types + node scripts/check-packlist.js (201 files OK).
  • npm pack: tarball contains lib/typescript/*.d.ts (23 files); the emitted declarations only import react and react-native, no __DEV__/bun globals leak into them.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • New Features
    • The package now includes TypeScript declaration files, improving type support for TypeScript projects.
  • Bug Fixes
    • Download progress events continue to use the appropriate platform-specific source, helping ensure progress is reported consistently on Harmony and other platforms.
    • Error reporting for update checks and invalid updates remains unchanged. No other user-facing behavior changes are included in this update.

package.json `types` points at src/index.ts, so apps type-check this
package's sources and skipLibCheck does not apply. Two errors surfaced
after upgrading to 10.62.0:

- client.ts: the private emitError delegate was never read (TS6133 under
  noUnusedLocals). Remove it; tests now call reporter.emitError directly.
- clientDownload.ts: calling addListener on the union of
  DeviceEventEmitter and the NativeEventEmitter is not callable with RN
  0.88 types (TS2349). Branch into two calls; emitted JS behaves the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 17505dc8-bf4e-4c8e-857d-3ef58edd2d78
📥 Commits

Reviewing files that changed from the base of the PR and between d16715c and c654b9a.

📒 Files selected for processing: 4
  • src/__tests__/client.test.ts
  • src/__tests__/provider.render.test.tsx
  • src/client.ts
  • src/clientDownload.ts
💤 Files with no reviewable changes: 1
  • src/client.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The client’s private error-forwarding method is removed, and affected tests call client.reporter.emitError directly. Download progress listener registration uses separate platform-specific calls; the selected emitters and callback remain unchanged.

Changes: Error reporting call sites

Layer / File(s) Summary
Remove client error forwarding method
src/client.ts, src/__tests__/client.test.ts, src/__tests__/provider.render.test.tsx
The private emitError forwarding method is removed. The affected tests call client.reporter.emitError; their report assertions and other expectations are unchanged.

Download progress listener registration

Layer / File(s) Summary
Split platform-specific listener registration
src/clientDownload.ts
Downloader.performDownload registers the listener through separate calls. Harmony uses DeviceEventEmitter; other platforms use pushyNativeEventEmitter. The callback is unchanged.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to c654b

The change removes an unused private error-forwarder and preserves platform-specific download progress handling. No user-visible behavior change or actionable merge risk is identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Title check Warning The title references TypeScript configuration issues, but it claims the pull request ships compiled .d.ts files. The changes instead remove an unused delegate and split platform-specific addListener c… Update the title to describe the actual fixes, for example: "fix(types): resolve app tsconfig errors in React Native 0.88".
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
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.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3 files.

Full details: Title check

Explanation

The title references TypeScript configuration issues, but it claims the pull request ships compiled .d.ts files. The changes instead remove an unused delegate and split platform-specific addListener calls.

Resolution

Update the title to describe the actual fixes, for example: "fix(types): resolve app tsconfig errors in React Native 0.88".

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

package.json `types` pointed at src/index.ts, so an app's tsc compiled
this package's sources under the app's own tsconfig (noUnusedLocals, ...)
and React Native version, where skipLibCheck does not reach. Emit
declarations to lib/typescript with tsc --emitDeclarationOnly
(tsconfig.build.json), point `types` at them and ship them; `main` stays
src/index for Metro. prepack, the lint workflow and the publish action
build them, and check-packlist requires the `types` file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sunnylqm sunnylqm changed the title fix(types): compile cleanly under app tsconfigs on RN 0.88 fix(types): ship compiled .d.ts so app tsconfigs never check our sources Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sunnylqm
sunnylqm merged commit 19ae03d into master Oct 19, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant