diff --git a/.github/actions/javascript/bumpVersion/bumpVersion.ts b/.github/actions/javascript/bumpVersion/bumpVersion.ts index 85955ea81ff4..eba79c7c9edb 100644 --- a/.github/actions/javascript/bumpVersion/bumpVersion.ts +++ b/.github/actions/javascript/bumpVersion/bumpVersion.ts @@ -20,7 +20,7 @@ function updateNativeVersions(version: string) { .then(() => { console.log('Successfully updated Android!'); }) - .catch((err) => { + .catch((err: string | Error) => { console.error('Error updating Android'); core.setFailed(err); }); diff --git a/.github/actions/javascript/checkDeployBlockers/checkDeployBlockers.ts b/.github/actions/javascript/checkDeployBlockers/checkDeployBlockers.ts index bf94b136ce43..d51d68796070 100644 --- a/.github/actions/javascript/checkDeployBlockers/checkDeployBlockers.ts +++ b/.github/actions/javascript/checkDeployBlockers/checkDeployBlockers.ts @@ -60,7 +60,7 @@ const run = function (): Promise { core.setOutput('HAS_DEPLOY_BLOCKERS', false); } }) - .catch((error) => { + .catch((error: string | Error) => { console.error('A problem occurred while trying to communicate with the GitHub API', error); core.setFailed(error); }); diff --git a/.github/actions/javascript/getPreviousVersion/getPreviousVersion.ts b/.github/actions/javascript/getPreviousVersion/getPreviousVersion.ts index e725e302eee1..262b603124fa 100644 --- a/.github/actions/javascript/getPreviousVersion/getPreviousVersion.ts +++ b/.github/actions/javascript/getPreviousVersion/getPreviousVersion.ts @@ -1,5 +1,6 @@ import * as core from '@actions/core'; import {readFileSync} from 'fs'; +import type {PackageJson} from 'type-fest'; import * as versionUpdater from '@github/libs/versionUpdater'; const semverLevel = core.getInput('SEMVER_LEVEL', {required: true}); @@ -7,6 +8,10 @@ if (!semverLevel || !Object.values(versionUpdater.SEMANTIC_VERSION_LEVEL core.setFailed(`'Error: Invalid input for 'SEMVER_LEVEL': ${semverLevel}`); } -const {version: currentVersion}: {version: string} = JSON.parse(readFileSync('./package.json', 'utf8')); -const previousVersion = versionUpdater.getPreviousVersion(currentVersion, semverLevel); +const {version: currentVersion}: PackageJson = JSON.parse(readFileSync('./package.json', 'utf8')); +if (!currentVersion) { + core.setFailed('Error: Could not read package.json'); +} + +const previousVersion = versionUpdater.getPreviousVersion(currentVersion ?? '', semverLevel); core.setOutput('PREVIOUS_VERSION', previousVersion); diff --git a/.github/actions/javascript/reviewerChecklist/reviewerChecklist.ts b/.github/actions/javascript/reviewerChecklist/reviewerChecklist.ts index aabc6b33086a..f57ef6c36a04 100644 --- a/.github/actions/javascript/reviewerChecklist/reviewerChecklist.ts +++ b/.github/actions/javascript/reviewerChecklist/reviewerChecklist.ts @@ -90,7 +90,7 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems: number) { getNumberOfItemsFromReviewerChecklist() .then(checkIssueForCompletedChecklist) - .catch((err) => { + .catch((err: string | Error) => { console.error(err); core.setFailed(err); }); diff --git a/src/components/AttachmentPicker/index.native.tsx b/src/components/AttachmentPicker/index.native.tsx index 822a5650e758..d865ca044779 100644 --- a/src/components/AttachmentPicker/index.native.tsx +++ b/src/components/AttachmentPicker/index.native.tsx @@ -171,7 +171,7 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s */ const showDocumentPicker = useCallback( (): Promise => - RNDocumentPicker.pick(getDocumentPickerOptions(type)).catch((error) => { + RNDocumentPicker.pick(getDocumentPickerOptions(type)).catch((error: TypeError) => { if (RNDocumentPicker.isCancel(error)) { return; } diff --git a/src/components/Composer/index.tsx b/src/components/Composer/index.tsx index f7bf277050a2..bead38512780 100755 --- a/src/components/Composer/index.tsx +++ b/src/components/Composer/index.tsx @@ -123,7 +123,7 @@ function Composer( if (shouldCalculateCaretPosition && isRendered) { // we do flushSync to make sure that the valueBeforeCaret is updated before we calculate the caret position to receive a proper position otherwise we will calculate position for the previous state flushSync(() => { - setValueBeforeCaret(webEvent.target.value.slice(0, webEvent.nativeEvent.selection.start)); + setValueBeforeCaret((webEvent.target as HTMLInputElement).value.slice(0, webEvent.nativeEvent.selection.start)); setCaretContent(getNextChars(value ?? '', webEvent.nativeEvent.selection.start)); }); const selectionValue = { diff --git a/src/components/Icon/__mocks__/Expensicons.ts b/src/components/Icon/__mocks__/Expensicons.ts index 78ad86210bf0..e268b109f0a5 100644 --- a/src/components/Icon/__mocks__/Expensicons.ts +++ b/src/components/Icon/__mocks__/Expensicons.ts @@ -1,4 +1,7 @@ -const Expensicons = jest.requireActual('../Expensicons'); +// eslint-disable-next-line import/no-import-module-exports +import type {SvgProps} from 'react-native-svg'; + +const Expensicons = jest.requireActual>>('../Expensicons'); module.exports = Object.keys(Expensicons).reduce((prev, curr) => { // We set the name of the anonymous mock function here so we can dynamically build the list of mocks and access the diff --git a/src/components/SignInButtons/AppleSignIn/index.ios.tsx b/src/components/SignInButtons/AppleSignIn/index.ios.tsx index 3fb1179d0365..4df8375edad8 100644 --- a/src/components/SignInButtons/AppleSignIn/index.ios.tsx +++ b/src/components/SignInButtons/AppleSignIn/index.ios.tsx @@ -1,4 +1,5 @@ import appleAuth from '@invertase/react-native-apple-authentication'; +import type {AppleError} from '@invertase/react-native-apple-authentication'; import React from 'react'; import IconButton from '@components/SignInButtons/IconButton'; import Log from '@libs/Log'; @@ -35,11 +36,11 @@ function AppleSignIn() { const handleSignIn = () => { appleSignInRequest() .then((token) => Session.beginAppleSignIn(token)) - .catch((e) => { - if (e.code === appleAuth.Error.CANCELED) { + .catch((error: {code: AppleError}) => { + if (error.code === appleAuth.Error.CANCELED) { return null; } - Log.alert('[Apple Sign In] Apple authentication failed', e); + Log.alert('[Apple Sign In] Apple authentication failed', error); }); }; return ( diff --git a/src/libs/Pusher/pusher.ts b/src/libs/Pusher/pusher.ts index cdce408d8d43..d4e17846d412 100644 --- a/src/libs/Pusher/pusher.ts +++ b/src/libs/Pusher/pusher.ts @@ -36,7 +36,9 @@ type PusherEventMap = { [TYPE.USER_IS_LEAVING_ROOM]: UserIsLeavingRoomEvent; }; -type EventData = EventName extends keyof PusherEventMap ? PusherEventMap[EventName] : OnyxUpdatesFromServer; +type EventData = {chunk?: string; id?: string; index?: number; final?: boolean} & (EventName extends keyof PusherEventMap + ? PusherEventMap[EventName] + : OnyxUpdatesFromServer); type EventCallbackError = {type: ValueOf; data: {code: number}}; @@ -164,7 +166,7 @@ function bindEventToChannel(channel: Channel return; } - let data; + let data: EventData; try { data = isObject(eventData) ? eventData : JSON.parse(eventData); } catch (err) { @@ -187,7 +189,9 @@ function bindEventToChannel(channel: Channel // Add it to the rolling list. const chunkedEvent = chunkedDataEvents[data.id]; - chunkedEvent.chunks[data.index] = data.chunk; + if (data.index !== undefined) { + chunkedEvent.chunks[data.index] = data.chunk; + } // If this is the last packet, mark that we've hit the end. if (data.final) { diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index 5f8fa228d191..0f13062b2e94 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -5,6 +5,7 @@ import {addSeconds, format, subMinutes, subSeconds} from 'date-fns'; import {utcToZonedTime} from 'date-fns-tz'; import React from 'react'; import {AppState, DeviceEventEmitter, Linking} from 'react-native'; +import type {ViewStyle} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type Animated from 'react-native-reanimated'; @@ -157,7 +158,10 @@ function scrollUpToRevealNewMessagesBadge() { function isNewMessagesBadgeVisible(): boolean { const hintText = Localize.translateLocal('accessibilityHints.scrollToNewestMessages'); const badge = screen.queryByAccessibilityHint(hintText); - return Math.round(badge?.props.style.transform[0].translateY) === -40; + const badgeProps = badge?.props as {style: ViewStyle}; + const transformStyle = badgeProps.style.transform?.[0] as {translateY: number}; + + return Math.round(transformStyle.translateY) === -40; } function navigateToSidebar(): Promise { diff --git a/tests/utils/collections/reportActions.ts b/tests/utils/collections/reportActions.ts index 65cbb3ba966e..111062f0c63e 100644 --- a/tests/utils/collections/reportActions.ts +++ b/tests/utils/collections/reportActions.ts @@ -2,17 +2,16 @@ import {rand, randAggregation, randBoolean, randWord} from '@ngneat/falso'; import {format} from 'date-fns'; import CONST from '@src/CONST'; import type {ReportAction} from '@src/types/onyx'; +import type {ActionName} from '@src/types/onyx/OriginalMessage'; +import type DeepRecord from '@src/types/utils/DeepRecord'; -type ActionType = keyof typeof CONST.REPORT.ACTIONS.TYPE; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const flattenActionNamesValues = (actionNames: any) => { - let result = [] as ActionType[]; - Object.keys(actionNames).forEach((key) => { - if (typeof actionNames[key] === 'object') { - result = result.concat(flattenActionNamesValues(actionNames[key])); +const flattenActionNamesValues = (actionNames: DeepRecord) => { + let result: ActionName[] = []; + Object.values(actionNames).forEach((value) => { + if (typeof value === 'object') { + result = result.concat(flattenActionNamesValues(value)); } else { - result.push(actionNames[key]); + result.push(value); } }); return result; @@ -81,4 +80,4 @@ export default function createRandomReportAction(index: number): ReportAction { }; } -export {getRandomDate}; +export {getRandomDate, flattenActionNamesValues};