Skip to content

chore(mobile): fix pre-existing type-check errors - #128

Merged
thomasluizon merged 1 commit into
mainfrom
chore/fix-mobile-type-check
Jun 5, 2026
Merged

chore(mobile): fix pre-existing type-check errors#128
thomasluizon merged 1 commit into
mainfrom
chore/fix-mobile-type-check

Conversation

@thomasluizon

Copy link
Copy Markdown
Owner

What

Fixes the pre-existing apps/mobile type-check failures on main. npm run type-check was RED with 20 errors across 16 files in otherwise-untouched code:

  • SafeAreaView (react-native-safe-area-context) — Property 'style' does not exist on type '... & NativeSafeAreaViewProps & ...' (14 screens)
  • GestureHandlerRootView (react-native-gesture-handler) — same style error (app/_layout.tsx)
  • components/habits/bulk-action-bar-v2.tsxBinding element 'pressed' implicitly has an 'any' type (5 occurrences)

These were blocking type-check validation for in-flight UI PRs (surfaced while implementing #116).

Root cause

Not 16 separate code bugs — one module-resolution failure manifesting everywhere:

react-native is installed under apps/mobile/node_modules, while react-native-safe-area-context and react-native-gesture-handler hoist to the repo-root node_modules. Under moduleResolution: "bundler", when tsc checks those hoisted libraries' .d.ts files, their import { ViewProps } from "react-native" is resolved by walking up from the repo root — which never finds react-native (it lives down in apps/mobile/node_modules). --traceResolution confirms: Module name 'react-native' was not resolved (15 times, all from the two hoisted libs).

With RN's types unresolved, NativeSafeAreaViewProps extends ViewProps and GestureHandlerRootViewProps lose style, and gesture-handler Pressable's render-prop callback arg degrades to implicit any. The app code was always correct.

Fix

Map react-native / react-native/* in apps/mobile/tsconfig.json to the actual install location, so every consumer .d.ts resolves a single RN type surface:

"react-native": ["./node_modules/react-native"],
"react-native/*": ["./node_modules/react-native/*"]

Root-cause config fix per Code Standard #1no app-code changes, no casts, no any, no @ts-ignore/eslint-disable. Verified pressed now infers boolean (not silently any) via a deliberate type-mismatch probe.

Validation (in worktree)

  • turbo run type-check — GREEN, all 3 workspaces (mobile + web + shared), 0 errors
  • turbo run lint — GREEN (no --fix needed)
  • apps/mobile unit tests — 361 passed / 81 files

No Closes — no tracked issue.

🤖 Generated with Claude Code

apps/mobile type-check was RED on main with 20 errors across 16 files:
SafeAreaView / GestureHandlerRootView "style" prop "does not exist", and an
implicitly-any "pressed" arg in bulk-action-bar-v2.tsx.

Root cause: react-native is installed under apps/mobile/node_modules while
react-native-safe-area-context and react-native-gesture-handler hoist to the
repo-root node_modules. With moduleResolution "bundler", those hoisted libs
resolve their `import ... from "react-native"` by walking UP from the repo
root and never find react-native (it lives down in apps/mobile/node_modules),
so their .d.ts files fail to resolve RN. That makes
`NativeSafeAreaViewProps extends ViewProps` and `GestureHandlerRootViewProps`
lose `style`, and the gesture-handler Pressable render-prop arg degrade to any.

Fix: map "react-native" / "react-native/*" in apps/mobile/tsconfig.json to the
actual install location so every consumer .d.ts resolves a single RN type
surface. No app code changes, no casts, no suppressions. "pressed" now infers
boolean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
orbit-ui-mobile-web Ignored Ignored Jun 4, 2026 5:30pm

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Correct root-cause fix for the 20 pre-existing type-check errors. Adding react-native / react-native/* path mappings to apps/mobile/tsconfig.json is exactly the right lever: it tells tsc where react-native actually lives (workspace-local node_modules) so hoisted packages like react-native-safe-area-context and react-native-gesture-handler can resolve their own ViewProps imports, restoring the missing style prop and the inferred boolean type on the gesture-handler pressed arg. No app code touched, no suppressions, no casts — purely a config fix per Code Standard #1.

@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2026

Copy link
Copy Markdown

@thomasluizon
thomasluizon merged commit e687b9a into main Jun 5, 2026
8 checks passed
@thomasluizon
thomasluizon deleted the chore/fix-mobile-type-check branch June 5, 2026 00:05
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