Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change .web files to default and add .native #2835

Merged
merged 4 commits into from
Apr 2, 2024
Merged

Conversation

m-bert
Copy link
Contributor

@m-bert m-bert commented Mar 27, 2024

Description

This PR moves content of .web files into default ones, which are replaced by .native. We do this because metro is good at resolving those types of files, but other bundlers are not.

Change in tsconfig assures, that types are correctly resolved.

Test plan

Built and played a little bit with example app on:

  • Web
  • iOS
  • Android

Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

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

👏

@m-bert m-bert merged commit e3e0b79 into main Apr 2, 2024
1 check passed
@m-bert m-bert deleted the @mbert/web-modules-default branch April 2, 2024 07:57
m-bert added a commit that referenced this pull request Apr 4, 2024
## Description

Our latest fails on CI were caused by outdated `typescript` in example app.  #2835 added `moduleSuffixes` into `compilerOptions` in `tsconfig.json`, but this option was added in version 4.7 of `typescript` and our example app currently has version 4.5.5.

This PR updates `typescript` version in our example app to much version in the root.

## Test plan

Check that CI passes.
@Zoxive
Copy link

Zoxive commented Apr 30, 2024

After getting latest with this change, Full types for FlatList, TextInput, etc are all missing.

(Locally I'm on typescript 5.4.5)

import { FlatList, TextInput } from 'react-native-gesture-handler';

export function NotificationsPage() {
  const notificationIds = ['one', 'two']
  const textInputRef = useRef<TextInput>(null); // ERROR 'TextInput' refers to a value, but is being used as a type here
  
  return (
  <View style={styles.container}>
	  <FlatList
		  data={notificationIds}
		  renderItem={({ item }) => <NotificationBarItem notificationId={item} />}
		  keyExtractor={(item) => item} // ERROR item is unknown 
	  />
  </View>
);
}

Im not sure what the correct fix is. I first thought i could simply export the types in https://github.com/software-mansion/react-native-gesture-handler/blob/main/src/index.ts but the types seem to work fine inside the repository directly. (Because ts resolves the .native.tsx file)

Im guessing that the types were lost when the NPM package was bundled?

@hirbod
Copy link

hirbod commented May 4, 2024

@m-bert i think this PR should be reverted or fixed asap.

It breaks types on a wide range of projects. Some more insight here #2889 (comment)

@m-bert
Copy link
Contributor Author

m-bert commented May 7, 2024

Hi @hirbod! I agree with you, it has to be dealt with quickly. Fixing that would take a while, so we decided to revert it (#2896) since it is not necessary right now.

j-piasecki pushed a commit that referenced this pull request May 7, 2024
)

## Description

This reverts commit e3e0b79.

#2835 was the first PR that was meant to introduce compatibility with
`Next.js`. Unfortunately, it broke types outside of our repository. Our
`tsconfig.json` has special flag, i.e. `moduleSuffixes`, which allows
`tsc` to look for `.native` files first. Most of our users do not have
this flag and they've run into `ts` problems, like this one:

```
'TextInput' refers to a value, but is being used as a type here. Did you mean 'typeof TextInput'?
```

Given that removing `moduleSuffixes` from `tsconfig` results in a bunch
of errors (and there are more of them that we may not be aware of), we
decided that it will be better to revert this change for now. It is not
necessary since we only need it to support `Next.js`. At first I thought
that #2873 may help, but unfortunately it doesn't.

Fixes #2889

## Test plan

1. Check that web, Android and iOS work as they did before
2. Check that code from [this
comment](#2835 (comment))
now does not throw any errors
github-merge-queue bot referenced this pull request in valora-inc/wallet Jun 6, 2024
…5520)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[react-native-gesture-handler](https://togithub.com/software-mansion/react-native-gesture-handler)
| [`^2.16.0` ->
`^2.16.2`](https://renovatebot.com/diffs/npm/react-native-gesture-handler/2.16.0/2.16.2)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/react-native-gesture-handler/2.16.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-native-gesture-handler/2.16.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-native-gesture-handler/2.16.0/2.16.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-native-gesture-handler/2.16.0/2.16.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>software-mansion/react-native-gesture-handler
(react-native-gesture-handler)</summary>

###
[`v2.16.2`](https://togithub.com/software-mansion/react-native-gesture-handler/releases/tag/2.16.2)

[Compare
Source](https://togithub.com/software-mansion/react-native-gesture-handler/compare/2.16.1...2.16.2)

##### 🐛 Bug fixes

- Revert "Change `.web` files to default and add `.native`
([#&#8203;2835](https://togithub.com/software-mansion/react-native-gesture-handler/issues/2835))"
by [@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2896](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2896)

##### 🔢 Miscellaneous

- Add examples to Gestures section in docs by
[@&#8203;xnameTM](https://togithub.com/xnameTM) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2876](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2876)
- Fix missing styles in gestures' InteractiveExamples by
[@&#8203;patrycjakalinska](https://togithub.com/patrycjakalinska) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2897](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2897)

**Full Changelog**:
software-mansion/react-native-gesture-handler@2.16.1...2.16.2

###
[`v2.16.1`](https://togithub.com/software-mansion/react-native-gesture-handler/releases/tag/2.16.1)

[Compare
Source](https://togithub.com/software-mansion/react-native-gesture-handler/compare/2.16.0...2.16.1)

#### 🐛 Bug fixes

- Fix remote debugger detection in bridgeless mode by
[@&#8203;piaskowyk](https://togithub.com/piaskowyk) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2864](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2864)
- Fix `manualActivation` on web by
[@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2869](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2869)
- Fix old Gesture Handler API integration with Reaniamted by
[@&#8203;piaskowyk](https://togithub.com/piaskowyk) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2881](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2881)
- \[Web] Fix incorrect `startX` and `startY` values in `Pan` by
[@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2871](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2871)
- \[Web] Add `minVelocity` to `Pan` custom activation criteria by
[@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2884](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2884)

#### 👍 Improvements

- Add `TypeDoc` to new API by
[@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2874](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2874)

#### 🔢 Miscellaneous

- Bump Gesture Handler version in documentation by
[@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2838](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2838)
- Change `.web` files to default and add `.native` by
[@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2835](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2835)
- Bump `typescript` version in example by
[@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2848](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2848)
- Disable flipper on CI by [@&#8203;m-bert](https://togithub.com/m-bert)
in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2843](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2843)
- Update supported RN versions by
[@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2849](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2849)
- Add state flow charts to Gesture Handler's documentation. by
[@&#8203;latekvo](https://togithub.com/latekvo) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2817](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2817)
- Fix `cancell` typo by [@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2854](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2854)
- Minor TS changes by [@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2872](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2872)
- Add automatic og:image generation to docs by
[@&#8203;xnameTM](https://togithub.com/xnameTM) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2851](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2851)
- Fix typo in og:image generation by
[@&#8203;kacperkapusciak](https://togithub.com/kacperkapusciak) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2880](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2880)
- Bump React Native in FabricExample to 0.74 by
[@&#8203;m-bert](https://togithub.com/m-bert) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2877](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2877)
- Update yarn setup in the repository by
[@&#8203;j-piasecki](https://togithub.com/j-piasecki) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2882](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2882)
- Release 2.16.1 by
[@&#8203;j-piasecki](https://togithub.com/j-piasecki) in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2883](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2883)

#### New Contributors

- [@&#8203;xnameTM](https://togithub.com/xnameTM) made their first
contribution in
[https://github.com/software-mansion/react-native-gesture-handler/pull/2851](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2851)

**Full Changelog**:
software-mansion/react-native-gesture-handler@2.16.0...2.16.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone
America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone
America/Los_Angeles.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/valora-inc/wallet).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zODguMSIsInVwZGF0ZWRJblZlciI6IjM3LjM4OC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJucG0iLCJyZW5vdmF0ZSJdfQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: valora-bot <[email protected]>
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.

5 participants