-
-
Notifications
You must be signed in to change notification settings - Fork 992
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 to TS #1327
Merged
Merged
Rewrite to TS #1327
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: WoLewicki <wojciech.lewicki@swmansion.com>
## Description ### Session 3: Honky Tonk Rewrite Last part of the TS rewrite process, in this PR we transfer types from declaration files to their implementations and add missing types for other functions and components. Change lists are probably not exhaustive but we tried to write most of the changes. ## Changes ### TS - Removed declaration files for Swipeable and DrawerLayout components. - Added types compatibility layer for the new types (`gestureHandlerTypesCompat.ts`). - Added generation of declarations and declarations map when TS is transpiled. #### Internal - Added types for all files used in RN. - Added basic types for the web version. - Mark web base classes as abstract (DiscreteGH, DraggingGH, etc). ### Source code - Added `"browser"` target and updated targets for source and types for Swipeable and DrawerLayout components `package.json`s. - Removed babel config for the main module, moved to examples. - Changed `"react-native"` entry point to `index.ts` (this ensures that clients using RN will load source instead of TS transpiled files). - Changed `"types"` to `"dist/index.d.ts"`. #### Internal - Changed most underscore prefixed function to non-prefixed, private functions. - Removed not used functions and arguments. - Replaced `x && x()` with `x.?()` in various places. - Removed prop types and replace them with lists of strings when necessary. ### Misc #### Internal - [Changed some TS-specific Eslint rules to "warn" mode.](https://github.com/software-mansion/react-native-gesture-handler/pull/1291/files#diff-6884918dc8291219be508e05e28965b958c734def85324f3b53858ea4702090fR22-R26) - Removed `no-use-before-define` rule. - Example's Eslint config extends root config. - Added support for the web version of Examples. - `State` and `NativeViewGestureHandler` are now named export internally. - Renamed `Gestures` to `gestureHandlers `. - Added `lint` npm script. ## TODO - [ ] Fill diff between master / ts-rewrite and this PR - [x] Update links referencing files in the docs - [ ] List all deprecations and breaking changes - [x] List all notable changes - [ ] Review TODOs, `eslint-ignore`s, `@ts-ignore`s, and `@ts-nocheck`s ## Missing types - [x] `src/components/GestureComponents.web.tsx` - [x] `src/web/DiscreteGestureHandler.ts` - [x] `src/web/DraggingGestureHandler.ts` - [x] `src/web/FlingGestureHandler.ts` - [x] `src/web/GestureHandler.ts` - [x] `src/web/IndiscreteGestureHandler.ts` - [x] `src/web/LongPressGestureHandler.ts` - [x] `src/web/NativeViewGestureHandler.ts` - [x] `src/web/PanGestureHandler.ts` - [x] `src/web/PinchGestureHandler.ts` - [x] `src/web/PressGestureHandler.ts` - [x] `src/web/RotationGestureHandler.ts` - [x] `src/web/TapGestureHandler.ts` ## Further improvements mentioned in review comments - #1291 (comment) ## Test plan This will be tested by manually checking examples. Future PRs can be checked by comparing bundle output (create two packages from master and this branch using `npm pack`, install one and then second later, create two bundles via `yarn react-native bundle --entry-file=index.js --bundle-output=rngh.bundle --reset-cache --minify=false`, and compare results with `diff rngh.bundle rngh.ts.bundle`). This PR is too big (18k diff) so we didn't do that. Co-authored-by: Jakub <jakub.gonet@swmansion.com> Co-authored-by: WoLewicki <wojciech.lewicki@swmansion.com>
WoLewicki
reviewed
Feb 3, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Left some comments.
Thanks @WoLewicki for huge help with that. |
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 <wojciech.lewicki@swmansion.com> Co-authored-by: Jakub <jakub.gonet@swmansion.com>
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 <wojciech.lewicki@swmansion.com> Co-authored-by: Jakub <jakub.gonet@swmansion.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
package.json
sdist/
Internal
_name
toprivate name
x && x()
syntax withx.?()
Types
gestureHandlerTypesCompat.ts
)Example app
Testing
PRs that were merged into
ts-rewrite
branch were tested by usingnpm 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 byfind src -name "*.js" -type f -exec sed -i '' '/import/d' {} \;