Skip to content

Conversation

kirstilynn
Copy link
Contributor

🧠 Context

This component previously used:

// @ts-ignore supported on web
cursor: 'grab',

to support cursor styling on the web platform. However, this still triggers a TypeScript error when using "jsx": "react-native" or when TypeScript re-validates style against ViewStyle — because the inferred object type includes cursor, which isn't allowed on native.

Even with "skipLibCheck": true, the error shows up at usage, not declaration, so @ts-ignore isn't enough.


✅ What’s fixed

The style is now wrapped in a platform check:

container: {
  ...(Platform.OS === 'web'
    ? { padding: 10, cursor: 'grab' }
    : { padding: 10 }),
},

This ensures the cursor property only exists at runtime when Platform.OS === 'web', so it's no longer included in the type — and TS no longer complains when passing it to a <View style={...}>.


📌 Why this matters

  • Removes the need for @ts-ignore
  • Fixes valid TS errors that still happen despite the ignore
  • Maintains behavior for web with zero runtime impact elsewhere

Let me know if you'd like to validate this further or want additional changes.

@gorhom gorhom self-requested a review September 4, 2025 18:45
@gorhom gorhom self-assigned this Sep 4, 2025
@gorhom gorhom changed the title fix: Conditionally apply web-only cursor style to avoid TypeScript error fix: conditionally apply web-only cursor style to avoid TypeScript error Sep 4, 2025
@gorhom gorhom merged commit e5c077b into gorhom:master Sep 4, 2025
@gorhom
Copy link
Owner

gorhom commented Sep 4, 2025

thanks for @kirstilynn for submitting this PR 🙌

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.

2 participants