fix: six real bugs the old TypeScript config was hiding - #1
Merged
Merged
Conversation
React Native stays on 0.68 — moving to 0.87 crosses the New Architecture and means regenerating the native projects, which needs Xcode and the Android SDK to verify. This covers the JavaScript side, where TypeScript 4.5 plus `suppressImplicitAnyIndexErrors` was hiding real problems. - TextInput imported `deviceType` from the utils barrel, which only re-exports it as `isIOS`. The import was undefined at runtime, so `if (!deviceType) return 14` always took the first branch and the per-device font sizing never ran. - `Env` has eight members but `apiServer` defined six: `local` and `bcp` resolved to undefined, making the request base URL the string "undefined". The map is now Record<Env, string>, so a missing environment is a type error. - The anti-double-submit Button never guarded anything. It declared a `loading` prop and tracked `iLoading`, and setLoading(true) ran on press, but neither value was read anywhere. Presses during an in-flight onPress are now ignored. - Webview was not assignable to React Navigation's ScreenComponentType: it declared its own `route` shape. It now uses RouteProp with typed params. The `|| restProps` fallback beside it was dead — restProps only carries the connected props. - TabScreen required `homeTodoCount`, but its connect() is commented out, so it was always undefined and the badge always read 0. - __tests__/App-test.tsx imported '../App', while App.tsx lives in src/. On a case-insensitive filesystem that resolved to app.json, so React was handed an object. Toolchain - TypeScript 4.5 -> 5.9; 4.5 could not parse the installed @types/node. Dropped `suppressImplicitAnyIndexErrors`, removed in TS 5.5. 0 type errors. - Test stack realigned: it was jest 25 with babel-jest 28, @types/jest 27 and react-test-renderer 16 against React 18. Now jest 29 throughout. - transformIgnorePatterns matches the React Native packages anywhere in the path: pnpm nests them under node_modules/.pnpm/, and the preset's own pattern assumes a flat node_modules. - The whole-<App /> render test is replaced by 17 unit tests over the validation helpers. Rendering the full app needs every native module mocked and does not finish in CI. - ESLint accepts _-prefixed unused bindings. 0 errors. - Migrate to pnpm. Docs - English README_EN.md alongside the Chinese readme.md, both stating plainly where React Native stands. - New CHANGELOG.md, bilingual CONTRIBUTING.md, and a CI workflow that runs lint, type-check and tests (not the app builds). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
React Native stays on 0.68. Moving to 0.87 crosses the New Architecture (Fabric / TurboModules) and means regenerating
ios/andandroid/— work that needs Xcode and the Android SDK to verify, not something the JavaScript side can settle. This PR covers everything that can be done without them.TypeScript 4.5 could not even parse the installed
@types/node, andsuppressImplicitAnyIndexErrors(removed in TS 5.5) was suppressing the rest. Upgrading to 5.9 and dropping that flag surfaced six genuine bugs — five of them runtime, not type-only.The bugs
TextInputimporteddeviceTypefrom theutilsbarrel, which only re-exports it under its aliasisIOS. The import wasundefined, soif (!deviceType) return 14always took the first branch.Envhas eight members;apiServerdefined six.localandbcpresolved toundefined, making the request base URL the literal string"undefined". Now typedRecord<Env, string>, so a missing environment is a compile error.loadingprop, trackediLoading, and calledsetLoading(true)on press — but neither value was read anywhere in the component. Repeat presses went straight through. Presses during an in-flightonPressare now ignored.Webviewwas not a valid navigation screenrouteshape, not assignable to React Navigation'sScreenComponentType. Now usesRoutePropwith typed params. The|| restPropsfallback beside it was dead code —restPropsonly carries the connected props, neverurl/header/disableBottom.TabScreenrequiredhomeTodoCount, but itsconnect()is commented out, so nothing supplied it.__tests__/App-test.tsximported'../App', whileApp.tsxlives insrc/. On a case-insensitive filesystem that resolved toapp.json, so React was handed an object.Toolchain
suppressImplicitAnyIndexErrorsremoved. 0 type errors.@types/jest27, and react-test-renderer 16 against React 18. Now jest 29 throughout.transformIgnorePatternsmatches the React Native packages anywhere in the path — pnpm nests them undernode_modules/.pnpm/…and the preset's own pattern assumes a flatnode_modules.<App />render test is replaced by 17 unit tests over the validation helpers (phone, bank card, ID card, URL, and the password rules). Rendering the full app needs every native module mocked and does not finish in CI._-prefixed unused bindings. 0 errors.Docs
README_EN.mdalongside the Chinesereadme.md, both with badges and a plain statement of where React Native stands.CHANGELOG.mdand bilingualCONTRIBUTING.md.ci.ymlrunning lint, type-check and tests on Node 20 and 22 — deliberately not the app builds.Verified
pnpm lint(0 errors),pnpm tslint(0 errors) andpnpm test(17 passing) all pass. The native builds were not run.🤖 Generated with Claude Code