software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
6.13k stars 982 forks source link

Certain classes (ScrollView, RNGHTextInput) no longer exporting type #2889

Closed johnnywang closed 6 months ago

johnnywang commented 6 months ago

Description

After updating to 2.16.1, I'm getting TypeScript errors in my code from several packages exported by RNGH when used in refs. Namely, ScrollView and RNGHTextInput will now error out with something like 'ScrollViewType' refers to a value, but is being used as a type here. Did you mean 'typeof ScrollViewType'?

Looking online, it seems this results from the type not being exported anymore, with some suggestions being to use InstanceType<typeof ScrollView> in place of it, but that only seems to throw different errors.

Opening as a bug because I didn't see any notes in the changelog about breaking changes, so this doesn't seem intentional.

Steps to reproduce

  1. Upgrade to 2.16.1
  2. Use ScrollView or RNGHTextInput inside something like a useRef

Snack or a link to a repository

n/a

Gesture Handler version

2.16.1

React Native version

0.72.10

Platforms

Android, iOS

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 6 months ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

huextrat commented 6 months ago

It seems to have been broken from: https://github.com/software-mansion/react-native-gesture-handler/pull/2835

hirbod commented 6 months ago

I also reported this on Discord, but I'll add following:

Hey folks, RNGH 2.16.1 is breaking types.

actually problem is that gesture handler has moved the typings to .native.d.ts file in 2.16.1 and our setup now only looks for .d.ts.

interestingly when i added it to moduleSuffixes, our modules on web started picking .native.tsx.

We had to downgrade back to 2.16.0 - we'd appreciate a fix or rollback

m-bert commented 6 months ago

Hi @johnnywang! We decided to revert faulty PR (#2896). I'll make sure to let you know when we release patched version.

m-bert commented 6 months ago

We've just released 2.16.2 😄 It would be great if you could confirm that the errors are gone after upgrading to the newest version!

renchap commented 6 months ago

I can confirm this has been fixed in 2.16.2, I no longer have TS errors