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

Rewrite Examples to TS #1273

Merged
merged 83 commits into from
Dec 17, 2020
Merged

Rewrite Examples to TS #1273

merged 83 commits into from
Dec 17, 2020

Conversation

jakub-gonet
Copy link
Member

@jakub-gonet jakub-gonet commented Dec 12, 2020

Description

Session 1: Example Blues

Fixes #1017.

This is the first part of moving into Typescript. Using TS types in Examples will allow us to test breaking changes to TS types API in the future PRs.

Note

During the rewrite, we spotted that RNGH TouchableNativeFeedback type in react-native-gesture-handler.d.ts does not expose static fields of RN's implementation. This is something that should be fixed in follow-up PRs.

Changes

  • Removed unused bits in examples
  • Regenerated Example app with latest RN
  • Added Eslint & Prettier config file in the root directory
  • Removed stray files from examples/
  • Updated Travis config to include newer Android build tools & iOS scheme name change
  • Moved Example code into src/
  • Removed Example tests

Test plan

I ran a diff on two npm packed version of the library and only changes that were present were related to reformatting.

Manually investigating TS errors & running example app.

TODO

  • Rewrite every example to TS
  • Make sure this change won't break packaging the library
  • Test every example on Android
  • Test every example on iOS
  • Test every example on Web We don't have setup ready, this can be verified in the follow-up PRs.

@jakub-gonet jakub-gonet changed the base branch from master to ts-rewrite December 12, 2020 11:41
Copy link
Member Author

@jakub-gonet jakub-gonet left a comment

Choose a reason for hiding this comment

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

Reviewed most of the configuration.

  1. IMO examples/App.tsx should be removed Resolved in dcd454e
  2. ExampleTests.m should be commented out (or wrapped in ifdef) – those tests won't work but they may be convenient for future reference. Resolved in 830ee3c
  3. We should re-add MBFingerTipWindow lib, it's used for creating GIFs of RNGH and presentations. Resolved in 392a5ea
  4. We should add the new logo of SWM instead of only removing the old one Already done, didn't notice.

examples/Example/android/gradle.properties Outdated Show resolved Hide resolved
examples/Example/app.json Outdated Show resolved Hide resolved
examples/Example/config.tsx Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
@jakub-gonet jakub-gonet marked this pull request as ready for review December 14, 2020 21:37
Copy link
Contributor

@jkadamczyk jkadamczyk left a comment

Choose a reason for hiding this comment

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

If that's not too much of work we can think of getting rid of some of these _underscore prefixed class fields

@jakub-gonet jakub-gonet merged commit 8ad2f16 into ts-rewrite Dec 17, 2020
@jakub-gonet jakub-gonet deleted the @wolewicki/example-to-ts branch December 17, 2020 12:58
@jakub-gonet jakub-gonet restored the @wolewicki/example-to-ts branch December 17, 2020 12:58
@jakub-gonet jakub-gonet mentioned this pull request Feb 2, 2021
jakub-gonet added a commit that referenced this pull request Feb 8, 2021
## Description

This PR combines three others (#1273, #1280, #1291) and rewrites Gesture Handler and examples to TS.
We tried to make non-breaking changes but this should be tested.

Most types were overhauled, although they should remain compatible with old ones thanks to the type aliases in the `src/handlers/gestureHandlerTypesCompat.ts` file.

CI for iOS was disabled due to strange fails. It should be reenabled when we add unit/e2e tests to RNGH.

Fixes #1076 - removed Flow from DrawerLayout
Fixes #1261 - added TS types
Fixes #998 - regenerated example app
Fixes #887 - removed prop types

## Changes

### Package packing, configs & source code

- Swipeable and DrawerLayout are now resolved by their own `package.json`s
- React Native uses source code directly, browser and TS use files from `dist/`
- Removed prop types

#### Internal

- Removed unused babel config in the root dir, adjust Eslint config
- Removed unused functions
- Changed private names from `_name` to `private name`
- Replaced `x && x()` syntax with `x.?()`

### Types

- Added types compatibility layer for the new types (`gestureHandlerTypesCompat.ts`)
- Added generation of declarations and declarations map when TS is transpiled
- Moved types from declaration files to files with implementation
- Added types to Android / iOS / shared JS code
- Added basic types to the web version

### Example app

- Removed unused bits in examples
- Regenerated Example app with latest RN
- Removed stray files from examples/
- Updated Travis config to include newer Android build tools & iOS scheme name change
- Organized Example code structure
- Removed Example tests (they weren't testing anything)
- Reconfigured web version of examples

## Testing

PRs that were merged into `ts-rewrite` branch were tested by using `npm pack` and adding it to the new app. In the case of #1273 & #1280, we additionally checked bundled diff for changes.

We diffed master to generated dist/ directory using `diff --color -wryN -W 200 src/ dist/src`with imports removed by `find src -name "*.js" -type f -exec sed -i '' '/import/d' {} \;`

Co-authored-by: WoLewicki <[email protected]>
Co-authored-by: Jakub <[email protected]>
mrousavy pushed a commit to mrousavy/react-native-gesture-handler that referenced this pull request Feb 11, 2021
This PR combines three others (software-mansion#1273, software-mansion#1280, software-mansion#1291) and rewrites Gesture Handler and examples to TS.
We tried to make non-breaking changes but this should be tested.

Most types were overhauled, although they should remain compatible with old ones thanks to the type aliases in the `src/handlers/gestureHandlerTypesCompat.ts` file.

CI for iOS was disabled due to strange fails. It should be reenabled when we add unit/e2e tests to RNGH.

Fixes software-mansion#1076 - removed Flow from DrawerLayout
Fixes software-mansion#1261 - added TS types
Fixes software-mansion#998 - regenerated example app
Fixes software-mansion#887 - removed prop types

- Swipeable and DrawerLayout are now resolved by their own `package.json`s
- React Native uses source code directly, browser and TS use files from `dist/`
- Removed prop types

- Removed unused babel config in the root dir, adjust Eslint config
- Removed unused functions
- Changed private names from `_name` to `private name`
- Replaced `x && x()` syntax with `x.?()`

- Added types compatibility layer for the new types (`gestureHandlerTypesCompat.ts`)
- Added generation of declarations and declarations map when TS is transpiled
- Moved types from declaration files to files with implementation
- Added types to Android / iOS / shared JS code
- Added basic types to the web version

- Removed unused bits in examples
- Regenerated Example app with latest RN
- Removed stray files from examples/
- Updated Travis config to include newer Android build tools & iOS scheme name change
- Organized Example code structure
- Removed Example tests (they weren't testing anything)
- Reconfigured web version of examples

PRs that were merged into `ts-rewrite` branch were tested by using `npm pack` and adding it to the new app. In the case of software-mansion#1273 & software-mansion#1280, we additionally checked bundled diff for changes.

We diffed master to generated dist/ directory using `diff --color -wryN -W 200 src/ dist/src`with imports removed by `find src -name "*.js" -type f -exec sed -i '' '/import/d' {} \;`

Co-authored-by: WoLewicki <[email protected]>
Co-authored-by: Jakub <[email protected]>
braincore pushed a commit to braincore/react-native-gesture-handler that referenced this pull request Mar 4, 2021
## Description

This PR combines three others (software-mansion#1273, software-mansion#1280, software-mansion#1291) and rewrites Gesture Handler and examples to TS.
We tried to make non-breaking changes but this should be tested.

Most types were overhauled, although they should remain compatible with old ones thanks to the type aliases in the `src/handlers/gestureHandlerTypesCompat.ts` file.

CI for iOS was disabled due to strange fails. It should be reenabled when we add unit/e2e tests to RNGH.

Fixes software-mansion#1076 - removed Flow from DrawerLayout
Fixes software-mansion#1261 - added TS types
Fixes software-mansion#998 - regenerated example app
Fixes software-mansion#887 - removed prop types

## Changes

### Package packing, configs & source code

- Swipeable and DrawerLayout are now resolved by their own `package.json`s
- React Native uses source code directly, browser and TS use files from `dist/`
- Removed prop types

#### Internal

- Removed unused babel config in the root dir, adjust Eslint config
- Removed unused functions
- Changed private names from `_name` to `private name`
- Replaced `x && x()` syntax with `x.?()`

### Types

- Added types compatibility layer for the new types (`gestureHandlerTypesCompat.ts`)
- Added generation of declarations and declarations map when TS is transpiled
- Moved types from declaration files to files with implementation
- Added types to Android / iOS / shared JS code
- Added basic types to the web version

### Example app

- Removed unused bits in examples
- Regenerated Example app with latest RN
- Removed stray files from examples/
- Updated Travis config to include newer Android build tools & iOS scheme name change
- Organized Example code structure
- Removed Example tests (they weren't testing anything)
- Reconfigured web version of examples

## Testing

PRs that were merged into `ts-rewrite` branch were tested by using `npm pack` and adding it to the new app. In the case of software-mansion#1273 & software-mansion#1280, we additionally checked bundled diff for changes.

We diffed master to generated dist/ directory using `diff --color -wryN -W 200 src/ dist/src`with imports removed by `find src -name "*.js" -type f -exec sed -i '' '/import/d' {} \;`

Co-authored-by: WoLewicki <[email protected]>
Co-authored-by: Jakub <[email protected]>
@jakub-gonet jakub-gonet deleted the @wolewicki/example-to-ts branch July 28, 2021 13:04
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.

3 participants