Skip to content

Commit fb4e121

Browse files
jgonetWoLewicki
authored andcommitted
Rewrite to TS (software-mansion#1327)
## 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]>
1 parent cfdf991 commit fb4e121

File tree

191 files changed

+17866
-12506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+17866
-12506
lines changed

.eslintrc.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"extends": [
3+
"plugin:@typescript-eslint/recommended",
4+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
5+
"satya164"
6+
],
7+
"settings": {
8+
"react": { "version": "16" },
9+
"import/resolver": {
10+
"babel-module": {}
11+
}
12+
},
13+
"parser": "@typescript-eslint/parser",
14+
"parserOptions": {
15+
"project": "./tsconfig.json"
16+
},
17+
"env": { "browser": true, "node": true, "jest/globals": true },
18+
"plugins": ["jest"],
19+
"ignorePatterns": ["dist/**/*"],
20+
"rules": {
21+
// temporary, remove after we type internals better
22+
"@typescript-eslint/restrict-template-expressions": "warn",
23+
"@typescript-eslint/no-unsafe-member-access": "warn",
24+
"@typescript-eslint/no-unsafe-call": "warn",
25+
"@typescript-eslint/no-unsafe-assignment": "warn",
26+
"@typescript-eslint/no-unsafe-return": "warn",
27+
28+
// common
29+
"@typescript-eslint/explicit-module-boundary-types": "off",
30+
"import/named": "off",
31+
"react/sort-comp": "off",
32+
"prefer-const": [
33+
"error",
34+
{
35+
"destructuring": "all"
36+
}
37+
],
38+
"@typescript-eslint/no-unused-vars": [
39+
"error",
40+
{ "argsIgnorePattern": "^_" }
41+
],
42+
"no-redeclare": "off",
43+
"@typescript-eslint/no-redeclare": "error",
44+
"no-use-before-define": "off",
45+
"@typescript-eslint/no-use-before-define": "error",
46+
"@typescript-eslint/ban-ts-comment": [
47+
"error",
48+
{
49+
"ts-ignore": "allow-with-description",
50+
"ts-expect-error": "allow-with-description"
51+
}
52+
]
53+
}
54+
}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ buck-out/
4545
!debug.keystore
4646

4747
# Expo
48-
/.expo
48+
.expo/
49+
web-build/
4950

5051
# vscode
5152
jsconfig.json
5253
.classpath
5354
.project
5455
.settings/
5556
.vscode
57+
58+
# TS
59+
dist/

.travis.yml

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
11
matrix:
22
include:
3-
- language: objective-c
4-
os: osx
5-
osx_image: xcode12.2
6-
xcode_workspace: './e2e/ios/ExampleE2E.xcworkspace'
7-
xcode_scheme: ExampleE2E
8-
podfile: './e2e/ios/Podfile'
9-
xcode_sdk: iphonesimulator12.4
10-
xcode_destination: platform=iOS Simulator,OS=12.4,name=iPhone X
11-
env: NODE_VERSION=10.19.0
3+
# Fix this config
4+
# - language: objective-c
5+
# os: osx
6+
# osx_image: xcode12.2
7+
# xcode_workspace: './e2e/ios/ExampleE2E.xcworkspace'
8+
# xcode_scheme: ExampleE2E
9+
# podfile: './e2e/ios/Podfile'
10+
# xcode_sdk: iphonesimulator12.4
11+
# xcode_destination: platform=iOS Simulator,OS=12.4,name=iPhone X
12+
# env: NODE_VERSION=10.19.0
1213

13-
branches:
14-
only:
15-
- master
14+
# branches:
15+
# only:
16+
# - master
1617

17-
cache: yarn
18+
# cache: yarn
1819

19-
install:
20-
- nvm --version
21-
- echo $NODE_VERSION
22-
- sudo launchctl limit maxfiles 2048 unlimited
23-
- sudo ulimit -n 10000
24-
- brew tap wix/brew
25-
- brew install applesimutils
26-
- nvm install $NODE_VERSION
27-
- nvm use $NODE_VERSION
28-
- nvm alias default $NODE_VERSION
29-
- brew install yarn --ignore-dependencies
30-
- npm install -g react-native-cli
31-
- npm install -g detox-cli
32-
- yarn
33-
- cd ci/e2e
34-
- yarn
35-
- cd ios
36-
- pod install
37-
- cd ..
38-
- export PRODUCT_BUNDLE_IDENTIFIER="com.swmansion.rn_gesture_handler_example"
39-
- detox build -c ios.sim.release | xcpretty
40-
script:
41-
- detox test -c ios.sim.release --no-color --headless --cleanup
20+
# install:
21+
# - nvm --version
22+
# - echo $NODE_VERSION
23+
# - sudo launchctl limit maxfiles 2048 unlimited
24+
# - sudo ulimit -n 10000
25+
# - brew tap wix/brew
26+
# - brew install applesimutils
27+
# - nvm install $NODE_VERSION
28+
# - nvm use $NODE_VERSION
29+
# - nvm alias default $NODE_VERSION
30+
# - brew install yarn --ignore-dependencies
31+
# - npm install -g react-native-cli
32+
# - npm install -g detox-cli
33+
# - yarn
34+
# - cd ci/e2e
35+
# - yarn
36+
# - cd ios
37+
# - pod install
38+
# - cd ..
39+
# - export PRODUCT_BUNDLE_IDENTIFIER="com.swmansion.rn_gesture_handler_example"
40+
# - detox build -c ios.sim.release | xcpretty
41+
# script:
42+
# - detox test -c ios.sim.release --no-color --headless --cleanup
4243

4344
- language: android
4445
dist: trusty
@@ -57,8 +58,9 @@ matrix:
5758
components:
5859
- tools
5960
- platform-tools
61+
- build-tools-29.0.2
6062
- build-tools-28.0.3
61-
- android-28
63+
- android-29
6264
install:
6365
- nvm install $NODE_VERSION
6466
- nvm use $NODE_VERSION
@@ -76,8 +78,8 @@ matrix:
7678
- language: objective-c
7779
os: osx
7880
osx_image: xcode12.2
79-
xcode_workspace: './Example/ios/GestureHandler.xcworkspace'
80-
xcode_scheme: GestureHandler
81+
xcode_workspace: './Example/ios/Example.xcworkspace'
82+
xcode_scheme: Example
8183
podfile: './Example/ios/Podfile'
8284
xcode_sdk: iphonesimulator12.2
8385
xcode_destination: platform=iOS Simulator,OS=12.2,name=iPhone X
@@ -107,4 +109,19 @@ matrix:
107109
- export PRODUCT_BUNDLE_IDENTIFIER="com.swmansion.rn_gesture_handler_example"
108110

109111
script:
110-
- xcodebuild -workspace ios/GestureHandler.xcworkspace -destination 'platform=iOS Simulator,OS=12.2,name=iPhone X' -scheme GestureHandler -parallelizeTargets -configuration Debug -derivedDataPath ios/build -UseModernBuildSystem=YES
112+
- xcodebuild -workspace ios/Example.xcworkspace -destination 'platform=iOS Simulator,OS=12.2,name=iPhone X' -scheme Example -parallelizeTargets -configuration Debug -derivedDataPath ios/build -UseModernBuildSystem=YES | xcpretty
113+
114+
- language: node_js
115+
node_js:
116+
- 12
117+
cache:
118+
directories:
119+
- node_modules
120+
script:
121+
- yarn
122+
- yarn tsc --noEmit
123+
- yarn lint-check
124+
- cd examples/Example
125+
- yarn
126+
- yarn tsc --noEmit
127+
- yarn lint-check

DrawerLayout.d.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

DrawerLayout.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

DrawerLayout/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"main": "../dist/src/components/DrawerLayout",
3+
"react-native": "../src/components/DrawerLayout",
4+
"browser": "../src/components/DrawerLayout",
5+
"types": "../dist/src/components/DrawerLayout.d.ts"
6+
}

Swipeable.d.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

Swipeable.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

Swipeable/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"main": "../dist/src/components/Swipeable",
3+
"react-native": "../src/components/Swipeable",
4+
"browser": "../src/components/Swipeable",
5+
"types": "../dist/src/components/Swipeable.d.ts"
6+
}

babel.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)