Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/view-focus-capture-optional-rn-prop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@plextv/react-native-lightning': patch
---

`View`'s `onFocusCapture` type no longer assumes `react-native`'s `ViewProps` declares the prop. react-native-tvos has it, plain react-native doesn't, so the indexed access was a hard `check:types` error for anyone on upstream react-native. Reads the prop only when it's actually present, so both forks typecheck.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ jobs:
- name: Lint
run: pnpm run lint

- name: Check types
run: pnpm run check:types

- name: Run unit tests
run: pnpm run test
8 changes: 7 additions & 1 deletion packages/react-native-lightning/src/exports/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import { useLayoutHandler } from '../hooks/useLayoutHandler';
import type { NativeLightningViewElement } from '../types/NativeLightningViewElement';
import { isFocusActive, shouldRegisterFocus } from './focusableView';

// react-native-tvos declares onFocusCapture on ViewProps, plain react-native
// doesn't. Generic so the indexed access stays deferred and compiles on both.
type FocusCaptureOf<P> = 'onFocusCapture' extends keyof P
? P['onFocusCapture']
: never;

type CombinedProps = Omit<
RNViewProps &
LightningViewElementProps &
Expand All @@ -28,7 +34,7 @@ type CombinedProps = Omit<
// intersecting them yields a signature no handler can satisfy. Accept either.
onFocusCapture?:
| FocusableProps['onFocusCapture']
| RNViewProps['onFocusCapture'];
| FocusCaptureOf<RNViewProps>;
// Directional-only focus catcher: reachable by a deliberate move but never
// by restoration or the mount-time default (drawer edge guard).
focusRestorationExcluded?: boolean;
Expand Down
Loading