Migrate source files to Typescript#1280
Merged
jgonet merged 28 commits intots-rewritefrom Dec 28, 2020
Merged
Conversation
jkadamczyk
reviewed
Dec 21, 2020
jkadamczyk
reviewed
Dec 21, 2020
WoLewicki
reviewed
Dec 21, 2020
| /* eslint-disable eslint-comments/no-unlimited-disable */ | ||
| /* eslint-disable */ | ||
| // @ts-nocheck TODO(TS) provide types | ||
| // @flow |
Member
Author
There was a problem hiding this comment.
Swipeable and Drawer were typed using TS but with // @flow comment added. Not sure why, this will be removed after we migrate types.
| /* eslint-disable eslint-comments/no-unlimited-disable */ | ||
| /* eslint-disable */ | ||
| // @ts-nocheck TODO(TS) provide types | ||
| // @flow |
tsconfig.json
Outdated
| "include": [ | ||
| "src/**/*.ts", | ||
| "src/**/*.tsx", | ||
| "src/**/*.d.ts", |
Member
Author
There was a problem hiding this comment.
This will be removed in the next PR.
Member
There was a problem hiding this comment.
Just commenting for convenience along with other comments of removal.
Just pleasing travis gods
jgonet
commented
Dec 28, 2020
Member
Author
|
I'm pretty sure this is ready so I'm going to merge it after CI passes. |
Merged
jgonet
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 <wojciech.lewicki@swmansion.com> Co-authored-by: Jakub <jakub.gonet@swmansion.com>
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>
This file contains hidden or 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
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
Session 2: Stray Typescript Strut
This PR renames files in RNGH & adds some TS config to prepare sources for the next PR that will add proper types for them.
Changes
Most of the files were renamed to use .ts(x) extension and given Eslint and TS ignores to ensure that errors won't prevent RNGH from building. They should be gradually removed as we add types.
Package.jsonchangesdist/directory has been included inpackage.jsonfilesproperty to ensure we're using transpiled sources. This created a problem with importing submodules (Swipeable, DrawerLayout) because setting the entry point doesn't change root directory for resolution. This makes distributing those much harder because we have to keep them as js files OR make some sort of hack to ensure importing them viaimport Swipeable from 'react-native-gesture-handler/Swipeable';will still work.The solution is to provide
exportsproperty to mapdiststructure to root directory and shadow it.However, this works on Node 14+. In order to preserve backwards compatibility,
Swipeable.jsandDrawerLayout.jsare exporting corresponding modules fromdist/directory. Alternative solutions to this problem would be to copy built js files to root dir or compile TS files into their location (removing dist/ directory). IMO the current way of doing this is the least invasive way.See microsoft/TypeScript#8305 and nodejs/node#14970 (comment) for more context.
Test plan
I manually packed RNGH and used a local file in the example project to test it. I tested Swipeable and draggable examples to test that RNGH still works correctly.
Diff between bundles of master and this branch (314bb40) versions of RNGH
As you may see, most differences are caused by changing line and column numbers, using files from
dist/, and renaming_variablestovariables. TS version doesn't include argument array copying, but I don't think this is dangerous.