Repository navigation
fix(types): ship compiled .d.ts so app tsconfigs never check our sources - #698
Conversation
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
package.jsontypespoints atsrc/index.ts, so apps runningtsc --noEmittype-check this package's TS sources under their own tsconfig and React Native version —skipLibCheckdoes not cover.tssources. After upgrading to 10.62.0, apps on RN 0.88 withnoUnusedLocalsget:src/client.ts:255TS6133 — the privateemitErrordelegate is never read.src/clientDownload.ts:180TS2349 —addListenercalled on the union ofDeviceEventEmitterand theNativeEventEmitter; their signatures no longer unify under RN 0.88 types.Fix
The two errors
emitErrordelegate (private, unreachable from outside). Tests now callreporter.emitErrordirectly.addListenercalls instead of calling on the union (no type assertion; runtime behavior unchanged).The root cause: ship compiled declarations
tsconfig.build.jsonemits declarations only (tsc --emitDeclarationOnly, the repo's own TS, no new dependency) fromsrc(minus__tests__) tolib/typescript.package.json:types→lib/typescript/index.d.ts;filesaddslib/typescript; newbuild:typesscript;prepackruns it after lint, sonpm publishalways ships fresh declarations.lib/is gitignored and excluded from the linttsc.mainstayssrc/index— Metro keeps bundling the TS sources exactly as before. Harmony (harmony/pushy.har,hvigor-plugin.ts) and codegen (codegenConfig.jsSrcsDir: src) are untouched.lint.ymland the publish action build the declarations beforecheck-packlist.js, which now requires the filetypesnames to be packed.Impact on existing users
tscnow reads.d.tsfiles, soskipLibCheckapplies and theirnoUnusedLocals/strictsettings or RN type differences can no longer surface errors from inside this package.react-native-update/src/xxxstill resolve to the TS sources (and are still checked by the app's tsc) — they were never public API.build:types:lib/typescriptis absent and TypeScript falls back tomain(src/index.ts), i.e. today's behavior.Verification
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 containslib/typescript/*.d.ts(23 files); the emitted declarations only importreactandreact-native, no__DEV__/bun globals leak into them.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit