From 43c24af566e0879e6ed22a92cf786cee8c87e51b Mon Sep 17 00:00:00 2001 From: fabriziofff Date: Fri, 14 Aug 2020 19:40:21 +0200 Subject: [PATCH] feat: [#165057751] Transpile typescript with babel (#2151) * [#173888442] update react-native-webview * [#173917003] upgrade redux saga to 1.1.3 * fix all typescript errors * fix delay * fix lint * fix lint * fix saga test * [#165057751] Migrate Typescript transpile to babel Co-authored-by: Matteo Boschi --- metro.config.js | 7 +++++- package.json | 1 - ts/__mocks__/react-native-keychain.ts | 2 +- ts/components/InstabugChatsComponent.tsx | 3 +-- ts/theme/fonts.ts | 2 +- ts/utils/keychain.ts | 2 +- tsconfig.json | 13 ++++++------ yarn.lock | 27 ++---------------------- 8 files changed, 18 insertions(+), 39 deletions(-) diff --git a/metro.config.js b/metro.config.js index 91a9ae04172..2e709bb90b1 100644 --- a/metro.config.js +++ b/metro.config.js @@ -1,5 +1,10 @@ module.exports = { transformer: { - babelTransformerPath: require.resolve('react-native-typescript-transformer') + getTransformOptions: async () => ({ + transform: { + experimentalImportSupport: false, + inlineRequires: false + } + }) } }; diff --git a/package.json b/package.json index 067702f753b..dd2e15c0ce0 100644 --- a/package.json +++ b/package.json @@ -168,7 +168,6 @@ "plist": "^3.0.1", "postinstall-postinstall": "^1.0.0", "prettier": "1.14.2", - "react-native-typescript-transformer": "^1.2.12", "react-test-renderer": "16.13.1", "redux-saga-test-plan": "4.0.0-rc.3", "rn-nodeify": "^10.0.1", diff --git a/ts/__mocks__/react-native-keychain.ts b/ts/__mocks__/react-native-keychain.ts index 0d7ae88a378..c9d39b2bece 100644 --- a/ts/__mocks__/react-native-keychain.ts +++ b/ts/__mocks__/react-native-keychain.ts @@ -2,7 +2,7 @@ * A mocked version of the Keychain */ -type KeychainDB = { +export type KeychainDB = { [key: string]: { username: string; password: string; diff --git a/ts/components/InstabugChatsComponent.tsx b/ts/components/InstabugChatsComponent.tsx index cf8c54b5f7a..c09d7786f28 100644 --- a/ts/components/InstabugChatsComponent.tsx +++ b/ts/components/InstabugChatsComponent.tsx @@ -17,7 +17,6 @@ import variables from "../theme/variables"; import ButtonDefaultOpacity from "./ButtonDefaultOpacity"; import CustomBadge from "./ui/CustomBadge"; import IconFont from "./ui/IconFont"; -import reportType = BugReporting.reportType; interface OwnProps { color?: string; @@ -79,7 +78,7 @@ class InstabugChatsComponent extends React.PureComponent { // Register to the instabug dismiss event. (https://docs.instabug.com/docs/react-native-bug-reporting-event-handlers#section-after-dismissing-instabug) // This event is fired when chat or bug screen is dismissed BugReporting.onSDKDismissedHandler( - (dismiss: dismissType, _: reportType): void => { + (dismiss: dismissType, _: BugReporting.reportType): void => { // Due an Instabug library bug, we can't use the report parameter because it always has "bug" as value. // We need to differentiate the type of report then use instabugReportType if (this.state.instabugReportType.isSome()) { diff --git a/ts/theme/fonts.ts b/ts/theme/fonts.ts index 506964d73e7..a9196e4f59b 100644 --- a/ts/theme/fonts.ts +++ b/ts/theme/fonts.ts @@ -28,7 +28,7 @@ const fontWeights = { type FontFamily = keyof typeof fonts; export type FontWeight = keyof typeof fontWeights; -const enum FontStyle { +enum FontStyle { "normal" = "normal", "italic" = "italic" } diff --git a/ts/utils/keychain.ts b/ts/utils/keychain.ts index 2c87863c2c6..a0718aba72f 100644 --- a/ts/utils/keychain.ts +++ b/ts/utils/keychain.ts @@ -22,7 +22,7 @@ const PIN_KEY = "PIN"; export async function setGenericPasswordWithDefaultAccessibleOption( username: string, password: string, - options?: Options + options?: Keychain.Options ) { return Keychain.setGenericPassword(username, password, { ...options, diff --git a/tsconfig.json b/tsconfig.json index 51c53371e80..3d897f6383d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { - "target": "es2015", - "module": "es2015", + "target": "esnext", + "module": "commonjs", + "lib": ["es6", "dom"], "jsx": "react", "noEmit": true, "moduleResolution": "node", @@ -16,14 +17,12 @@ "noUnusedParameters": true, "noUnusedLocals": true, "strictFunctionTypes": true, - "skipLibCheck": true + "skipLibCheck": true, + "isolatedModules": true }, - "lib": [ - "dom" - ], "exclude": [ "android", "ios", "node_modules" ] -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 5a1d3004d97..0dbac88b4cf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3095,7 +3095,7 @@ chalk@1.1.3, chalk@^1.0.0, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.0, chalk@^2.4.1, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -3965,7 +3965,7 @@ deepmerge@^3.2.0: resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-3.3.0.tgz#d3c47fd6f3a93d517b14426b0628a17b0125f5f7" integrity sha512-GRQOafGHwMHpjPx9iCvTgpu9NojZ49q794EEL94JVEw6VaeA8XTUyBKvAkOOjBX9oJNiV6G3P+T+tihFjo2TqA== -deepmerge@^4.0.0, deepmerge@^4.2.2: +deepmerge@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== @@ -4819,11 +4819,6 @@ find-cache-dir@^2.0.0: make-dir "^2.0.0" pkg-dir "^3.0.0" -find-root@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4" - integrity sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng== - find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -6690,11 +6685,6 @@ jetifier@^1.6.2: resolved "https://registry.yarnpkg.com/jetifier/-/jetifier-1.6.6.tgz#fec8bff76121444c12dc38d2dad6767c421dab68" integrity sha512-JNAkmPeB/GS2tCRqUzRPsTOHpGDah7xP18vGJfIjZC+W2sxEHbxgJxetIjIqhjQ3yYbYNEELkM/spKLtwoOSUQ== -jju@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a" - integrity sha1-o6vicYryQaKykE+EpiWXDzia4yo= - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -9375,19 +9365,6 @@ react-native-touch-id@^4.4.1: resolved "https://registry.yarnpkg.com/react-native-touch-id/-/react-native-touch-id-4.4.1.tgz#8b1bb2d04c30bac36bb9696d2d723e719c4a8b08" integrity sha512-1jTl8fC+0fxvqegy/XXTyo6vMvPhjzkoDdaqoYZx0OH8AT250NuXnNPyKktvigIcys3+2acciqOeaCall7lrvg== -react-native-typescript-transformer@^1.2.12: - version "1.2.13" - resolved "https://registry.yarnpkg.com/react-native-typescript-transformer/-/react-native-typescript-transformer-1.2.13.tgz#be92a3d110dbb2cf2f4aebe60a935be124cfb7ed" - integrity sha512-uLL6U9BirM+gKRZNKqJQW+m1onh+goiwDqG4+9XSy5dUhjmkjCkbx8j2eahie9hFcHJdnknJ6wRAEF5/7mGWmw== - dependencies: - babel-traverse "^6.26.0" - chalk "^2.4.0" - deepmerge "^4.0.0" - find-root "^1.1.0" - jju "^1.3.0" - semver "^5.4.1" - source-map "^0.5.6" - react-native-vector-icons@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/react-native-vector-icons/-/react-native-vector-icons-7.0.0.tgz#5b92ed363c867645daad48c559e1f99efcfbb813"