Skip to content

Commit 519d86f

Browse files
authored
[MOB-9374] Migrate to TypeScript (#783)
* Remove typescript_validator * Init TS structure * Bypass Compiler Errors Temporarily * Fix Example App * Re-export NativeModules * Format Files * Convert ArgsRegistry to Namespace * Add types to IBGEventEmitter * Add types to InstabugUtils * Move `FeatureRequests` to Typed Namespace * Move `APM` to Typed Namespace * Rename Native Modules JS Exports * Move `BugReporting` to Typed Namespace * Move `CrashReporting` to Typed Namespace * Move `Instabug` to Typed Namespace * Move `NetworkLogger` to Typed Namespace * Move `Replies` to Typed Namespace * Move `Surveys` to Typed Namespace * Remove `index.d.ts` * Change Constructors to Parameter Properties * Add `@apollo/client` Types * Add `react-native-navigation` Types * Add `react-navigation` Types * Refrence Enum types from `ArgsRegistry` * Improve Doc Comments and Param Names * Use Records * Fix Types Errors * Update Test Imports * Update `tsconfig.json` * Build SDK in Test/Publish CI Jobs * Build SDK in E2E CI Jobs * Export Models * Use `ts-jest` * Fix Failing Tests * Replace Namespaces with Modules * Change `InstabugConstants` to enum * Replace `var` with `let` and `const` * Improve types * Remove unnecessary assignment * Fix ArgsRegistry Metro Error * Add Missing Args to XHRInterceptor * Revert `setNetworkDataObfuscationHandler` Changes * Change TS Out Directory * Update Changelog
1 parent 37830a3 commit 519d86f

Some content is hidden

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

53 files changed

+2580
-3711
lines changed

.circleci/config.yml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ jobs:
1717
- checkout:
1818
path: ~/project
1919

20-
- run: yarn
21-
2220
- run:
23-
name: Typescript Definitions Validation
24-
command: node typescript_validator.js
21+
name: Install Node Packages
22+
command: yarn
2523

2624
- run:
2725
name: jest tests
@@ -113,16 +111,16 @@ jobs:
113111
name: Build and run tests
114112
command: cd ios && xcodebuild -allowProvisioningUpdates -workspace InstabugSample.xcworkspace -scheme InstabugSample -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13 Pro Max,OS=15.5' test | xcpretty
115113
no_output_timeout: 30m
114+
116115
e2e_ios:
117116
macos:
118117
xcode: 13.4.1
119118
resource_class: large
120-
working_directory: ~/project/example
119+
working_directory: ~/project
121120
environment:
122121
FL_OUTPUT_DIR: output
123122
steps:
124-
- checkout:
125-
path: ~/project
123+
- checkout
126124
- run:
127125
name: Install CocoaPods
128126
command: sudo gem install cocoapods
@@ -138,25 +136,34 @@ jobs:
138136
- run:
139137
name: Install Node Packages
140138
command: yarn
139+
- run:
140+
name: Build Project
141+
command: yarn build
142+
- run:
143+
name: Install Example's Node Packages
144+
working_directory: example
145+
command: yarn
141146
- run:
142147
name: Install Pods
143-
command: cd ios && pod install
148+
working_directory: example/ios
149+
command: pod install
144150
- run:
145151
name: Detox - Build Release App
152+
working_directory: example
146153
command: detox build --configuration ios.sim.release --cleanup
147154
- run:
148155
name: Detox - Run E2E Tests
156+
working_directory: example
149157
command: detox test --configuration ios.sim.release --cleanup
150158

151159
e2e_android:
152160
executor:
153161
name: android/android-machine
154162
tag: "2022.03.1"
155163
resource-class: large
156-
working_directory: ~/project/example/android
164+
working_directory: ~/project
157165
steps:
158-
- checkout:
159-
path: ~/project
166+
- checkout
160167
- run:
161168
name: Install Yarn
162169
command: npm install --global yarn
@@ -166,6 +173,13 @@ jobs:
166173
- run:
167174
name: Install Node Packages
168175
command: yarn
176+
- run:
177+
name: Build Project
178+
command: yarn build
179+
- run:
180+
name: Install Example's Node Packages
181+
working_directory: example
182+
command: yarn
169183
- android/create-avd:
170184
avd-name: Nexus_6P_API_27
171185
install: true
@@ -176,12 +190,12 @@ jobs:
176190
memory: 2048
177191
post-emulator-launch-assemble-command: |
178192
rm -rf ~/.gradle/caches
179-
./gradlew androidDependencies
180-
cd ..
181-
detox build -c android.emu.release
193+
cd ~/project/example/android && ./gradlew androidDependencies
194+
cd .. && detox build -c android.emu.release
182195
- run:
183196
name: Detox - Run E2E Tests
184-
command: cd .. && detox test -c android.emu.release
197+
working_directory: example
198+
command: detox test -c android.emu.release
185199

186200
publish:
187201
macos:
@@ -193,6 +207,7 @@ jobs:
193207
- run: git clone https://InstabugCI:[email protected]/Instabug/Escape.git
194208
- run: cd Escape && swift build -c release
195209
- run: cd Escape/.build/release && cp -f Escape /usr/local/bin/escape
210+
- run: cd project && yarn && yarn build
196211
- run: cd project && Escape react-native publish
197212

198213
workflows:

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ xcuserdata/
3232

3333

3434
coverage/
35+
.jest/cache/
3536
*node_modules/
3637
*Pods/
3738
*Podfile.lock
39+
40+
# Typescript build
41+
dist/

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ test/
2525
Dangerfile
2626
babel.config.js
2727
codecov.yml
28-
typescript_validator.js
2928
.prettierrc.js

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Unreleased
2+
3+
* Adds first-class TypeScript support.
4+
15
## 11.3.0 (2022-10-11)
26

37
* Bumps Instabug Android SDK to v11.5.1

jest.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
module.exports = {
3+
preset: 'react-native',
4+
testEnvironment: 'node',
5+
cacheDirectory: '.jest/cache',
6+
coverageDirectory: './coverage/',
7+
clearMocks: true,
8+
collectCoverage: true,
9+
collectCoverageFrom: ['./src/**/*.(js|ts)'],
10+
setupFilesAfterEnv: ['./tests/setup.js'],
11+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
12+
modulePathIgnorePatterns: ['example'],
13+
transform: {
14+
'^.+\\.jsx$': 'babel-jest',
15+
'^.+\\.tsx?$': [
16+
'ts-jest',
17+
{
18+
tsconfig: 'tsconfig.json',
19+
},
20+
],
21+
},
22+
};

package.json

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"homepage": "https://www.instabug.com/platforms/react-native",
88
"bugs": "https://github.com/Instabug/Instabug-React-Native/issues",
99
"license": "MIT",
10-
"main": "src/index.js",
11-
"types": "src/index.d.ts",
10+
"main": "dist/index",
11+
"types": "dist/index.d.ts",
12+
"react-native": "src/index.ts",
1213
"keywords": [
1314
"react-native",
1415
"instabug",
@@ -20,13 +21,19 @@
2021
"feedback"
2122
],
2223
"scripts": {
23-
"test": "jest"
24+
"test": "jest",
25+
"build": "tsc"
2426
},
2527
"peerDependencies": {
2628
"react": ">=16.8.6",
2729
"react-native": ">=0.60.0"
2830
},
2931
"devDependencies": {
32+
"@apollo/client": "^3.7.0",
33+
"@react-navigation/native": "^5.9.8",
34+
"@types/jest": "^24.0.0",
35+
"@types/node": "^18.7.23",
36+
"@types/react-native": "^0.66.0",
3037
"babel-core": "7.0.0-bridge.0",
3138
"babel-jest": "^24.8.0",
3239
"esprima": "^4.0.1",
@@ -35,23 +42,11 @@
3542
"nock": "^13.2.9",
3643
"react": "^16.8.6",
3744
"react-native": "^0.60.0",
38-
"typescript": "4.0.3",
45+
"react-native-navigation": "7.29.0",
46+
"react-navigation": "^4.4.4",
47+
"ts-jest": "^24.0.0",
48+
"typescript": "^4.8.4",
3949
"wait-for-expect": "^1.2.0",
4050
"xhr2": "^0.2.1"
41-
},
42-
"jest": {
43-
"preset": "react-native",
44-
"clearMocks": true,
45-
"coverageDirectory": "./coverage/",
46-
"collectCoverage": true,
47-
"collectCoverageFrom": [
48-
"./src/**/*.(js|ts)"
49-
],
50-
"setupFilesAfterEnv": [
51-
"./tests/setup.js"
52-
],
53-
"modulePathIgnorePatterns": [
54-
"example"
55-
]
5651
}
5752
}

0 commit comments

Comments
 (0)