From 9fc260da92c62bd0e48d6837648bd729e307122a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barbara=20Gawe=C5=82-Kucab?= Date: Tue, 28 May 2024 15:28:16 +0200 Subject: [PATCH] wip --- .storybook/webpack.config.ts | 9 ++++++--- config/webpack/webpack.common.ts | 3 ++- src/components/Tooltip/BaseTooltip/index.tsx | 3 ++- src/components/WalletStatementModal/index.tsx | 2 +- src/libs/Environment/betaChecker/index.android.ts | 2 +- src/libs/Environment/betaChecker/index.ios.ts | 5 +++-- src/libs/Environment/betaChecker/index.ts | 2 +- src/libs/Environment/betaChecker/types.ts | 6 +++++- src/libs/StartupTimer/index.native.ts | 3 +-- 9 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.storybook/webpack.config.ts b/.storybook/webpack.config.ts index 4d638020cd42..a083c35d6ee7 100644 --- a/.storybook/webpack.config.ts +++ b/.storybook/webpack.config.ts @@ -3,6 +3,7 @@ /* eslint-disable no-param-reassign */ /* eslint-disable @typescript-eslint/naming-convention */ +import type Environment from 'config/webpack/types'; import dotenv from 'dotenv'; import path from 'path'; import {DefinePlugin} from 'webpack'; @@ -18,6 +19,8 @@ type CustomWebpackConfig = { }; }; +type CustomWebpackFunctionProps = ({file, platform}: Environment) => CustomWebpackConfig; + let envFile: string; switch (process.env.ENV) { case 'production': @@ -31,9 +34,9 @@ switch (process.env.ENV) { } const env = dotenv.config({path: path.resolve(__dirname, `../${envFile}`)}); -const custom: CustomWebpackConfig = require('../config/webpack/webpack.common').default({ - envFile, -}); +const customFunction: CustomWebpackFunctionProps = require('../config/webpack/webpack.common'); + +const custom: CustomWebpackConfig = customFunction({file: envFile}); const webpackConfig = ({config}: {config: Configuration}) => { if (!config.resolve) { diff --git a/config/webpack/webpack.common.ts b/config/webpack/webpack.common.ts index 9d397b9557a3..5dbc3f182f1a 100644 --- a/config/webpack/webpack.common.ts +++ b/config/webpack/webpack.common.ts @@ -1,3 +1,4 @@ +import type WebpackPlugin from '@vue/preload-webpack-plugin'; import {CleanWebpackPlugin} from 'clean-webpack-plugin'; import CopyPlugin from 'copy-webpack-plugin'; import dotenv from 'dotenv'; @@ -11,7 +12,7 @@ import CustomVersionFilePlugin from './CustomVersionFilePlugin'; import type Environment from './types'; // require is necessary, there are no types for this package and the declaration file can't be seen by the build process which causes an error. -const PreloadWebpackPlugin = require('@vue/preload-webpack-plugin'); +const PreloadWebpackPlugin: typeof WebpackPlugin = require('@vue/preload-webpack-plugin'); const includeModules = [ 'react-native-animatable', diff --git a/src/components/Tooltip/BaseTooltip/index.tsx b/src/components/Tooltip/BaseTooltip/index.tsx index 5f6c38d19bff..0bfaa689d948 100644 --- a/src/components/Tooltip/BaseTooltip/index.tsx +++ b/src/components/Tooltip/BaseTooltip/index.tsx @@ -190,7 +190,8 @@ function Tooltip( (e: MouseEvent) => { updateTargetAndMousePosition(e); if (React.isValidElement(children)) { - children.props.onMouseEnter?.(e); + const onMouseEnter: (e: MouseEvent) => void | undefined = children.props.onMouseEnter; + onMouseEnter?.(e); } }, [children, updateTargetAndMousePosition], diff --git a/src/components/WalletStatementModal/index.tsx b/src/components/WalletStatementModal/index.tsx index d469eedc9761..9bc715db706f 100644 --- a/src/components/WalletStatementModal/index.tsx +++ b/src/components/WalletStatementModal/index.tsx @@ -18,7 +18,7 @@ function WalletStatementModal({statementPageURL, session}: WalletStatementProps) /** * Handles in-app navigation for iframe links */ - const navigate = (event: MessageEvent) => { + const navigate = (event: MessageEvent<{url: string; type: string}>) => { if (!event.data?.type || (event.data.type !== CONST.WALLET.WEB_MESSAGE_TYPE.STATEMENT && event.data.type !== CONST.WALLET.WEB_MESSAGE_TYPE.CONCIERGE)) { return; } diff --git a/src/libs/Environment/betaChecker/index.android.ts b/src/libs/Environment/betaChecker/index.android.ts index da65ae1b7383..975cddf210c9 100644 --- a/src/libs/Environment/betaChecker/index.android.ts +++ b/src/libs/Environment/betaChecker/index.android.ts @@ -4,7 +4,7 @@ import * as AppUpdate from '@libs/actions/AppUpdate'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import pkg from '../../../../package.json'; -import type IsBetaBuild from './types'; +import type {IsBetaBuild} from './types'; let isLastSavedBeta = false; Onyx.connect({ diff --git a/src/libs/Environment/betaChecker/index.ios.ts b/src/libs/Environment/betaChecker/index.ios.ts index dae79dabfd2b..05e3c7244a2a 100644 --- a/src/libs/Environment/betaChecker/index.ios.ts +++ b/src/libs/Environment/betaChecker/index.ios.ts @@ -1,12 +1,13 @@ import {NativeModules} from 'react-native'; -import type IsBetaBuild from './types'; +import type {EnvironmentCheckerProps, IsBetaBuild} from './types'; /** * Check to see if the build is staging (TestFlight) or production */ function isBetaBuild(): IsBetaBuild { return new Promise((resolve) => { - NativeModules.EnvironmentChecker.isBeta().then((isBeta: boolean) => { + const {EnvironmentChecker} = NativeModules; + (EnvironmentChecker as EnvironmentCheckerProps).isBeta().then((isBeta: boolean) => { resolve(isBeta); }); }); diff --git a/src/libs/Environment/betaChecker/index.ts b/src/libs/Environment/betaChecker/index.ts index ce1668759c8c..eaa8bfbc1500 100644 --- a/src/libs/Environment/betaChecker/index.ts +++ b/src/libs/Environment/betaChecker/index.ts @@ -1,4 +1,4 @@ -import type IsBetaBuild from './types'; +import type {IsBetaBuild} from './types'; /** * There's no beta build in non native diff --git a/src/libs/Environment/betaChecker/types.ts b/src/libs/Environment/betaChecker/types.ts index 61ce4bc9cec4..c519e0cb67f7 100644 --- a/src/libs/Environment/betaChecker/types.ts +++ b/src/libs/Environment/betaChecker/types.ts @@ -1,3 +1,7 @@ type IsBetaBuild = Promise; -export default IsBetaBuild; +type EnvironmentCheckerProps = { + isBeta: () => IsBetaBuild; +}; + +export type {IsBetaBuild, EnvironmentCheckerProps}; diff --git a/src/libs/StartupTimer/index.native.ts b/src/libs/StartupTimer/index.native.ts index 4e9c91222104..341bdbf25d99 100644 --- a/src/libs/StartupTimer/index.native.ts +++ b/src/libs/StartupTimer/index.native.ts @@ -6,8 +6,7 @@ import type StartupTimer from './types'; */ const startupTimer: StartupTimer = { stop: () => { - const {StartupTimer} = NativeModules; - (StartupTimer as StartupTimer).stop(); + (NativeModules.StartupTimer as StartupTimer).stop(); }, };