From 9ea9f18f1ae19dda2f906654cf1b9bb21115d7df Mon Sep 17 00:00:00 2001 From: RR3b3l0 Date: Thu, 21 Dec 2023 15:41:01 +0000 Subject: [PATCH 1/9] [TS migration] Migrate AnchorForAttachmentsOnly component --- .../AnchorForAttachmentsOnlyTypes.ts | 9 ++++ ...ly.js => BaseAnchorForAttachmentsOnly.tsx} | 48 ++++++++----------- .../anchorForAttachmentsOnlyPropTypes.js | 21 -------- .../{index.native.js => index.native.tsx} | 10 ++-- .../{index.js => index.tsx} | 11 ++--- 5 files changed, 37 insertions(+), 62 deletions(-) create mode 100644 src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts rename src/components/AnchorForAttachmentsOnly/{BaseAnchorForAttachmentsOnly.js => BaseAnchorForAttachmentsOnly.tsx} (70%) delete mode 100644 src/components/AnchorForAttachmentsOnly/anchorForAttachmentsOnlyPropTypes.js rename src/components/AnchorForAttachmentsOnly/{index.native.js => index.native.tsx} (50%) rename src/components/AnchorForAttachmentsOnly/{index.js => index.tsx} (58%) diff --git a/src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts b/src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts new file mode 100644 index 000000000000..e07b46a5b69b --- /dev/null +++ b/src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts @@ -0,0 +1,9 @@ +import {StyleProp, ViewStyle} from 'react-native'; + +type AnchorForAttachmentsOnlyProps = { + source: string; + displayName: string; + style: StyleProp; +}; + +export default AnchorForAttachmentsOnlyProps; diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.js b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx similarity index 70% rename from src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.js rename to src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 6161ba140726..af84d10b2649 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.js +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -1,6 +1,5 @@ -import PropTypes from 'prop-types'; import React from 'react'; -import {withOnyx} from 'react-native-onyx'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import AttachmentView from '@components/Attachments/AttachmentView'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import {ShowContextMenuContext, showContextMenuForReport} from '@components/ShowContextMenuContext'; @@ -10,37 +9,28 @@ import * as ReportUtils from '@libs/ReportUtils'; import * as Download from '@userActions/Download'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import {defaultProps as anchorForAttachmentsOnlyDefaultProps, propTypes as anchorForAttachmentsOnlyPropTypes} from './anchorForAttachmentsOnlyPropTypes'; +import {Download as OnyxDownload} from '@src/types/onyx'; +import AnchorForAttachmentsOnlyProps from './AnchorForAttachmentsOnlyTypes'; -const propTypes = { - /** Press in handler for the link */ - onPressIn: PropTypes.func, - - /** Press out handler for the link */ - onPressOut: PropTypes.func, - - /** If a file download is happening */ - download: PropTypes.shape({ - isDownloading: PropTypes.bool.isRequired, - }), - - ...anchorForAttachmentsOnlyPropTypes, +type BaseAnchorForAttachmentsOnlyPropsWithOnyx = { + download: OnyxEntry; }; -const defaultProps = { - onPressIn: undefined, - onPressOut: undefined, - download: {isDownloading: false}, - ...anchorForAttachmentsOnlyDefaultProps, -}; +type BaseAnchorForAttachmentsOnlyProps = { + /** Press in handler for the link */ + onPressIn?: () => void; + /** Press out handler for the link */ + onPressOut?: () => void; +} & AnchorForAttachmentsOnlyProps & + BaseAnchorForAttachmentsOnlyPropsWithOnyx; -function BaseAnchorForAttachmentsOnly(props) { +function BaseAnchorForAttachmentsOnly(props: BaseAnchorForAttachmentsOnlyProps) { const sourceURL = props.source; const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL); - const sourceID = (sourceURL.match(CONST.REGEX.ATTACHMENT_ID) || [])[1]; + const sourceID = (sourceURL.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; const fileName = props.displayName; - const isDownloading = props.download && props.download.isDownloading; + const isDownloading = props.download?.isDownloading; return ( @@ -56,11 +46,13 @@ function BaseAnchorForAttachmentsOnly(props) { }} onPressIn={props.onPressIn} onPressOut={props.onPressOut} + // @ts-expect-error TODO: Remove this once ShowContextMenuContext (https://github.com/Expensify/App/issues/24980) is migrated to TypeScript. onLongPress={(event) => showContextMenuForReport(event, anchor, report.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} accessibilityLabel={fileName} role={CONST.ROLE.BUTTON} > ({ download: { key: ({source}) => { - const sourceID = (source.match(CONST.REGEX.ATTACHMENT_ID) || [])[1]; + const sourceID = (source.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; return `${ONYXKEYS.COLLECTION.DOWNLOAD}${sourceID}`; }, }, diff --git a/src/components/AnchorForAttachmentsOnly/anchorForAttachmentsOnlyPropTypes.js b/src/components/AnchorForAttachmentsOnly/anchorForAttachmentsOnlyPropTypes.js deleted file mode 100644 index 9452e615d31c..000000000000 --- a/src/components/AnchorForAttachmentsOnly/anchorForAttachmentsOnlyPropTypes.js +++ /dev/null @@ -1,21 +0,0 @@ -import PropTypes from 'prop-types'; -import stylePropTypes from '@styles/stylePropTypes'; - -const propTypes = { - /** The URL of the attachment */ - source: PropTypes.string, - - /** Filename for attachments. */ - displayName: PropTypes.string, - - /** Any additional styles to apply */ - style: stylePropTypes, -}; - -const defaultProps = { - source: '', - style: {}, - displayName: '', -}; - -export {propTypes, defaultProps}; diff --git a/src/components/AnchorForAttachmentsOnly/index.native.js b/src/components/AnchorForAttachmentsOnly/index.native.tsx similarity index 50% rename from src/components/AnchorForAttachmentsOnly/index.native.js rename to src/components/AnchorForAttachmentsOnly/index.native.tsx index 3277d51ec058..4e1b9df77659 100644 --- a/src/components/AnchorForAttachmentsOnly/index.native.js +++ b/src/components/AnchorForAttachmentsOnly/index.native.tsx @@ -1,21 +1,19 @@ import React from 'react'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as anchorForAttachmentsOnlyPropTypes from './anchorForAttachmentsOnlyPropTypes'; +import AnchorForAttachmentsOnlyTypes from './AnchorForAttachmentsOnlyTypes'; import BaseAnchorForAttachmentsOnly from './BaseAnchorForAttachmentsOnly'; -function AnchorForAttachmentsOnly(props) { +function AnchorForAttachmentsOnly({source, displayName}: AnchorForAttachmentsOnlyTypes) { const styles = useThemeStyles(); return ( ); } -AnchorForAttachmentsOnly.propTypes = anchorForAttachmentsOnlyPropTypes.propTypes; -AnchorForAttachmentsOnly.defaultProps = anchorForAttachmentsOnlyPropTypes.defaultProps; AnchorForAttachmentsOnly.displayName = 'AnchorForAttachmentsOnly'; export default AnchorForAttachmentsOnly; diff --git a/src/components/AnchorForAttachmentsOnly/index.js b/src/components/AnchorForAttachmentsOnly/index.tsx similarity index 58% rename from src/components/AnchorForAttachmentsOnly/index.js rename to src/components/AnchorForAttachmentsOnly/index.tsx index 1dae62e771ef..546ddcdacae1 100644 --- a/src/components/AnchorForAttachmentsOnly/index.js +++ b/src/components/AnchorForAttachmentsOnly/index.tsx @@ -1,22 +1,21 @@ import React from 'react'; import ControlSelection from '@libs/ControlSelection'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; -import * as anchorForAttachmentsOnlyPropTypes from './anchorForAttachmentsOnlyPropTypes'; import BaseAnchorForAttachmentsOnly from './BaseAnchorForAttachmentsOnly'; +import AnchorForAttachmentsOnlyProps from './AnchorForAttachmentsOnlyTypes'; -function AnchorForAttachmentsOnly(props) { +function AnchorForAttachmentsOnly({source, displayName, style}: AnchorForAttachmentsOnlyProps) { return ( DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} /> ); } -AnchorForAttachmentsOnly.propTypes = anchorForAttachmentsOnlyPropTypes.propTypes; -AnchorForAttachmentsOnly.defaultProps = anchorForAttachmentsOnlyPropTypes.defaultProps; AnchorForAttachmentsOnly.displayName = 'AnchorForAttachmentsOnly'; export default AnchorForAttachmentsOnly; From 0d64fc9486635aec69fba2dfff43ddb36464c48e Mon Sep 17 00:00:00 2001 From: RR3b3l0 Date: Fri, 22 Dec 2023 09:32:45 +0000 Subject: [PATCH 2/9] [TS migration] AnchorForAttachmentsOnly - Code improvements --- .../AnchorForAttachmentsOnlyTypes.ts | 5 +++- .../BaseAnchorForAttachmentsOnly.tsx | 28 +++++++++---------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts b/src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts index e07b46a5b69b..91d2388eee20 100644 --- a/src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts +++ b/src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts @@ -1,9 +1,12 @@ import {StyleProp, ViewStyle} from 'react-native'; type AnchorForAttachmentsOnlyProps = { + /** The URL of the attachment */ source: string; + /** Filename for attachments. */ displayName: string; - style: StyleProp; + /** Any additional styles to apply */ + style?: StyleProp; }; export default AnchorForAttachmentsOnlyProps; diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index af84d10b2649..465b34f63128 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -16,27 +16,27 @@ type BaseAnchorForAttachmentsOnlyPropsWithOnyx = { download: OnyxEntry; }; -type BaseAnchorForAttachmentsOnlyProps = { - /** Press in handler for the link */ - onPressIn?: () => void; - /** Press out handler for the link */ - onPressOut?: () => void; -} & AnchorForAttachmentsOnlyProps & - BaseAnchorForAttachmentsOnlyPropsWithOnyx; +type BaseAnchorForAttachmentsOnlyProps = AnchorForAttachmentsOnlyProps & + BaseAnchorForAttachmentsOnlyPropsWithOnyx & { + /** Press in handler for the link */ + onPressIn?: () => void; + /** Press out handler for the link */ + onPressOut?: () => void; + }; -function BaseAnchorForAttachmentsOnly(props: BaseAnchorForAttachmentsOnlyProps) { - const sourceURL = props.source; +function BaseAnchorForAttachmentsOnly({style, source, displayName, download, onPressIn, onPressOut}: BaseAnchorForAttachmentsOnlyProps) { + const sourceURL = source; const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL); const sourceID = (sourceURL.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; - const fileName = props.displayName; + const fileName = displayName; - const isDownloading = props.download?.isDownloading; + const isDownloading = download?.isDownloading ?? false; return ( {({anchor, report, action, checkIfContextMenuActive}) => ( { if (isDownloading) { return; @@ -44,8 +44,8 @@ function BaseAnchorForAttachmentsOnly(props: BaseAnchorForAttachmentsOnlyProps) Download.setDownload(sourceID, true); fileDownload(sourceURLWithAuth, fileName).then(() => Download.setDownload(sourceID, false)); }} - onPressIn={props.onPressIn} - onPressOut={props.onPressOut} + onPressIn={onPressIn} + onPressOut={onPressOut} // @ts-expect-error TODO: Remove this once ShowContextMenuContext (https://github.com/Expensify/App/issues/24980) is migrated to TypeScript. onLongPress={(event) => showContextMenuForReport(event, anchor, report.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} accessibilityLabel={fileName} From a97ff6d3954ee520d823a1dce2bff313ceafbf22 Mon Sep 17 00:00:00 2001 From: RR3b3l0 Date: Fri, 22 Dec 2023 09:34:15 +0000 Subject: [PATCH 3/9] [TS migration] AnchorForAttachmentsOnly - Minor comment changes --- .../AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 465b34f63128..092b52cc9297 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -13,6 +13,7 @@ import {Download as OnyxDownload} from '@src/types/onyx'; import AnchorForAttachmentsOnlyProps from './AnchorForAttachmentsOnlyTypes'; type BaseAnchorForAttachmentsOnlyPropsWithOnyx = { + /** If a file download is happening */ download: OnyxEntry; }; From f9f4469b2288225ff4b2c73c51ccef0d8f175506 Mon Sep 17 00:00:00 2001 From: RR3b3l0 Date: Fri, 22 Dec 2023 09:55:14 +0000 Subject: [PATCH 4/9] [TS migration] AnchorForAttachmentsOnly - Code improvements --- .../BaseAnchorForAttachmentsOnly.tsx | 13 +++++++------ .../AnchorForAttachmentsOnly/index.native.tsx | 8 ++++---- src/components/AnchorForAttachmentsOnly/index.tsx | 9 ++++----- .../{AnchorForAttachmentsOnlyTypes.ts => types.ts} | 6 ++++-- 4 files changed, 19 insertions(+), 17 deletions(-) rename src/components/AnchorForAttachmentsOnly/{AnchorForAttachmentsOnlyTypes.ts => types.ts} (85%) diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 092b52cc9297..3dbdac2c10fe 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -10,22 +10,23 @@ import * as Download from '@userActions/Download'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import {Download as OnyxDownload} from '@src/types/onyx'; -import AnchorForAttachmentsOnlyProps from './AnchorForAttachmentsOnlyTypes'; +import AnchorForAttachmentsOnlyProps from './types'; -type BaseAnchorForAttachmentsOnlyPropsWithOnyx = { +type BaseAnchorForAttachmentsOnlyOnyxProps = { /** If a file download is happening */ download: OnyxEntry; }; type BaseAnchorForAttachmentsOnlyProps = AnchorForAttachmentsOnlyProps & - BaseAnchorForAttachmentsOnlyPropsWithOnyx & { + BaseAnchorForAttachmentsOnlyOnyxProps & { /** Press in handler for the link */ onPressIn?: () => void; + /** Press out handler for the link */ onPressOut?: () => void; }; -function BaseAnchorForAttachmentsOnly({style, source, displayName, download, onPressIn, onPressOut}: BaseAnchorForAttachmentsOnlyProps) { +function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', download, onPressIn, onPressOut}: BaseAnchorForAttachmentsOnlyProps) { const sourceURL = source; const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL); const sourceID = (sourceURL.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; @@ -67,10 +68,10 @@ function BaseAnchorForAttachmentsOnly({style, source, displayName, download, onP BaseAnchorForAttachmentsOnly.displayName = 'BaseAnchorForAttachmentsOnly'; -export default withOnyx({ +export default withOnyx({ download: { key: ({source}) => { - const sourceID = (source.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; + const sourceID = (source?.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; return `${ONYXKEYS.COLLECTION.DOWNLOAD}${sourceID}`; }, }, diff --git a/src/components/AnchorForAttachmentsOnly/index.native.tsx b/src/components/AnchorForAttachmentsOnly/index.native.tsx index 4e1b9df77659..7f043aa871cc 100644 --- a/src/components/AnchorForAttachmentsOnly/index.native.tsx +++ b/src/components/AnchorForAttachmentsOnly/index.native.tsx @@ -1,14 +1,14 @@ import React from 'react'; import useThemeStyles from '@hooks/useThemeStyles'; -import AnchorForAttachmentsOnlyTypes from './AnchorForAttachmentsOnlyTypes'; +import AnchorForAttachmentsOnlyProps from './types'; import BaseAnchorForAttachmentsOnly from './BaseAnchorForAttachmentsOnly'; -function AnchorForAttachmentsOnly({source, displayName}: AnchorForAttachmentsOnlyTypes) { +function AnchorForAttachmentsOnly(props: AnchorForAttachmentsOnlyProps) { const styles = useThemeStyles(); return ( ); diff --git a/src/components/AnchorForAttachmentsOnly/index.tsx b/src/components/AnchorForAttachmentsOnly/index.tsx index 546ddcdacae1..2e8e8320d412 100644 --- a/src/components/AnchorForAttachmentsOnly/index.tsx +++ b/src/components/AnchorForAttachmentsOnly/index.tsx @@ -2,14 +2,13 @@ import React from 'react'; import ControlSelection from '@libs/ControlSelection'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import BaseAnchorForAttachmentsOnly from './BaseAnchorForAttachmentsOnly'; -import AnchorForAttachmentsOnlyProps from './AnchorForAttachmentsOnlyTypes'; +import AnchorForAttachmentsOnlyProps from './types'; -function AnchorForAttachmentsOnly({source, displayName, style}: AnchorForAttachmentsOnlyProps) { +function AnchorForAttachmentsOnly(props: AnchorForAttachmentsOnlyProps) { return ( DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} /> diff --git a/src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts b/src/components/AnchorForAttachmentsOnly/types.ts similarity index 85% rename from src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts rename to src/components/AnchorForAttachmentsOnly/types.ts index 91d2388eee20..55c45db3d68f 100644 --- a/src/components/AnchorForAttachmentsOnly/AnchorForAttachmentsOnlyTypes.ts +++ b/src/components/AnchorForAttachmentsOnly/types.ts @@ -2,9 +2,11 @@ import {StyleProp, ViewStyle} from 'react-native'; type AnchorForAttachmentsOnlyProps = { /** The URL of the attachment */ - source: string; + source?: string; + /** Filename for attachments. */ - displayName: string; + displayName?: string; + /** Any additional styles to apply */ style?: StyleProp; }; From a62150d8f6eb63a20ebcba1dc19267f301afc600 Mon Sep 17 00:00:00 2001 From: RR3b3l0 Date: Wed, 27 Dec 2023 10:26:35 +0000 Subject: [PATCH 5/9] [ts migration] Removed unnecessary variable creation --- .../BaseAnchorForAttachmentsOnly.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 3dbdac2c10fe..47ce7bb2dc0b 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -27,10 +27,8 @@ type BaseAnchorForAttachmentsOnlyProps = AnchorForAttachmentsOnlyProps & }; function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', download, onPressIn, onPressOut}: BaseAnchorForAttachmentsOnlyProps) { - const sourceURL = source; - const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL); - const sourceID = (sourceURL.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; - const fileName = displayName; + const sourceURLWithAuth = addEncryptedAuthTokenToURL(source); + const sourceID = (source.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; const isDownloading = download?.isDownloading ?? false; @@ -44,19 +42,19 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow return; } Download.setDownload(sourceID, true); - fileDownload(sourceURLWithAuth, fileName).then(() => Download.setDownload(sourceID, false)); + fileDownload(sourceURLWithAuth, displayName).then(() => Download.setDownload(sourceID, false)); }} onPressIn={onPressIn} onPressOut={onPressOut} // @ts-expect-error TODO: Remove this once ShowContextMenuContext (https://github.com/Expensify/App/issues/24980) is migrated to TypeScript. onLongPress={(event) => showContextMenuForReport(event, anchor, report.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} - accessibilityLabel={fileName} + accessibilityLabel={displayName} role={CONST.ROLE.BUTTON} > From 8e199e566237aeb83b01694ea6c8860eb16c5318 Mon Sep 17 00:00:00 2001 From: ruben-rebelo Date: Mon, 8 Jan 2024 11:33:35 +0000 Subject: [PATCH 6/9] [TS migration] Prettier code changes --- src/components/AnchorForAttachmentsOnly/index.native.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AnchorForAttachmentsOnly/index.native.tsx b/src/components/AnchorForAttachmentsOnly/index.native.tsx index 7f043aa871cc..594a909907b8 100644 --- a/src/components/AnchorForAttachmentsOnly/index.native.tsx +++ b/src/components/AnchorForAttachmentsOnly/index.native.tsx @@ -1,7 +1,7 @@ import React from 'react'; import useThemeStyles from '@hooks/useThemeStyles'; -import AnchorForAttachmentsOnlyProps from './types'; import BaseAnchorForAttachmentsOnly from './BaseAnchorForAttachmentsOnly'; +import AnchorForAttachmentsOnlyProps from './types'; function AnchorForAttachmentsOnly(props: AnchorForAttachmentsOnlyProps) { const styles = useThemeStyles(); From 27dd6ebfb6ac31321ea81c43a24feaf3fdae0596 Mon Sep 17 00:00:00 2001 From: ruben-rebelo Date: Wed, 10 Jan 2024 09:26:41 +0000 Subject: [PATCH 7/9] [TS migration] Added type on import of types --- .../BaseAnchorForAttachmentsOnly.tsx | 6 +++--- src/components/AnchorForAttachmentsOnly/index.native.tsx | 2 +- src/components/AnchorForAttachmentsOnly/index.tsx | 2 +- src/components/AnchorForAttachmentsOnly/types.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 47ce7bb2dc0b..28e2141b01ff 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import {OnyxEntry, withOnyx} from 'react-native-onyx'; +import {type OnyxEntry, withOnyx} from 'react-native-onyx'; import AttachmentView from '@components/Attachments/AttachmentView'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import {ShowContextMenuContext, showContextMenuForReport} from '@components/ShowContextMenuContext'; @@ -9,8 +9,8 @@ import * as ReportUtils from '@libs/ReportUtils'; import * as Download from '@userActions/Download'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import {Download as OnyxDownload} from '@src/types/onyx'; -import AnchorForAttachmentsOnlyProps from './types'; +import type {Download as OnyxDownload} from '@src/types/onyx'; +import type AnchorForAttachmentsOnlyProps from './types'; type BaseAnchorForAttachmentsOnlyOnyxProps = { /** If a file download is happening */ diff --git a/src/components/AnchorForAttachmentsOnly/index.native.tsx b/src/components/AnchorForAttachmentsOnly/index.native.tsx index 594a909907b8..2e0e94bc0b88 100644 --- a/src/components/AnchorForAttachmentsOnly/index.native.tsx +++ b/src/components/AnchorForAttachmentsOnly/index.native.tsx @@ -1,7 +1,7 @@ import React from 'react'; import useThemeStyles from '@hooks/useThemeStyles'; import BaseAnchorForAttachmentsOnly from './BaseAnchorForAttachmentsOnly'; -import AnchorForAttachmentsOnlyProps from './types'; +import type AnchorForAttachmentsOnlyProps from './types'; function AnchorForAttachmentsOnly(props: AnchorForAttachmentsOnlyProps) { const styles = useThemeStyles(); diff --git a/src/components/AnchorForAttachmentsOnly/index.tsx b/src/components/AnchorForAttachmentsOnly/index.tsx index 2e8e8320d412..a81df9382e73 100644 --- a/src/components/AnchorForAttachmentsOnly/index.tsx +++ b/src/components/AnchorForAttachmentsOnly/index.tsx @@ -2,7 +2,7 @@ import React from 'react'; import ControlSelection from '@libs/ControlSelection'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import BaseAnchorForAttachmentsOnly from './BaseAnchorForAttachmentsOnly'; -import AnchorForAttachmentsOnlyProps from './types'; +import type AnchorForAttachmentsOnlyProps from './types'; function AnchorForAttachmentsOnly(props: AnchorForAttachmentsOnlyProps) { return ( diff --git a/src/components/AnchorForAttachmentsOnly/types.ts b/src/components/AnchorForAttachmentsOnly/types.ts index 55c45db3d68f..a5186d8c0d90 100644 --- a/src/components/AnchorForAttachmentsOnly/types.ts +++ b/src/components/AnchorForAttachmentsOnly/types.ts @@ -1,4 +1,4 @@ -import {StyleProp, ViewStyle} from 'react-native'; +import type {StyleProp, ViewStyle} from 'react-native'; type AnchorForAttachmentsOnlyProps = { /** The URL of the attachment */ From c8a0cc85c1f7ee1a79e21cedf744445596fd835e Mon Sep 17 00:00:00 2001 From: ruben-rebelo Date: Thu, 11 Jan 2024 14:11:14 +0000 Subject: [PATCH 8/9] [TS migration] Lint issue fix --- .../AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 28e2141b01ff..92aab9a04696 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import {type OnyxEntry, withOnyx} from 'react-native-onyx'; +import { withOnyx} from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; import AttachmentView from '@components/Attachments/AttachmentView'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import {ShowContextMenuContext, showContextMenuForReport} from '@components/ShowContextMenuContext'; From 8c5c7522b3da6e9e18cd5e607dc0151e74a91aff Mon Sep 17 00:00:00 2001 From: ruben-rebelo Date: Fri, 12 Jan 2024 09:32:22 +0000 Subject: [PATCH 9/9] [Ts migration] Prettified the code --- .../AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 92aab9a04696..df8a0a30b129 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withOnyx} from 'react-native-onyx'; +import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import AttachmentView from '@components/Attachments/AttachmentView'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';