From 4e9e40d959af817d302413ebfca5530c53e0ba89 Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Fri, 15 Sep 2023 15:30:23 +0200 Subject: [PATCH 1/3] Add types --- src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts diff --git a/src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts b/src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts new file mode 100644 index 000000000000..6616a13d8d23 --- /dev/null +++ b/src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts @@ -0,0 +1,4 @@ +// to keep same behavior from before migration +// eslint-disable-next-line @typescript-eslint/naming-convention +type GetOSAndName = () => {device_name: string | undefined; os_version: string | undefined}; +export default GetOSAndName; From 807a802b29b8202757afc6326b1d5b56b9a9f584 Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Fri, 15 Sep 2023 16:23:13 +0200 Subject: [PATCH 2/3] Migrate getOSAndName to typescript --- .../actions/Device/getDeviceInfo/getOSAndName/index.js | 4 ---- .../getOSAndName/{index.native.js => index.native.ts} | 9 +++++++-- .../actions/Device/getDeviceInfo/getOSAndName/index.ts | 10 ++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) delete mode 100644 src/libs/actions/Device/getDeviceInfo/getOSAndName/index.js rename src/libs/actions/Device/getDeviceInfo/getOSAndName/{index.native.js => index.native.ts} (61%) create mode 100644 src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts diff --git a/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.js b/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.js deleted file mode 100644 index 29b004412f64..000000000000 --- a/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// Don't import this file with '* as Device'. It's known to make VSCode IntelliSense crash. -import {getOSAndName} from 'expensify-common/lib/Device'; - -export default getOSAndName; diff --git a/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.native.js b/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.native.ts similarity index 61% rename from src/libs/actions/Device/getDeviceInfo/getOSAndName/index.native.js rename to src/libs/actions/Device/getDeviceInfo/getOSAndName/index.native.ts index 11d59abea1f1..455487d056f2 100644 --- a/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.native.js +++ b/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.native.ts @@ -1,11 +1,16 @@ import Str from 'expensify-common/lib/str'; import RNDeviceInfo from 'react-native-device-info'; +import GetOSAndName from './types'; -export default function getOSAndName() { +const getOSAndName: GetOSAndName = () => { const deviceName = RNDeviceInfo.getDeviceNameSync(); const prettyName = `${Str.UCFirst(RNDeviceInfo.getManufacturerSync() || '')} ${deviceName}`; return { + // eslint-disable-next-line @typescript-eslint/naming-convention device_name: RNDeviceInfo.isEmulatorSync() ? `Emulator - ${prettyName}` : prettyName, + // eslint-disable-next-line @typescript-eslint/naming-convention os_version: RNDeviceInfo.getSystemVersion(), }; -} +}; + +export default getOSAndName; diff --git a/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts b/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts new file mode 100644 index 000000000000..5155fc07afb2 --- /dev/null +++ b/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts @@ -0,0 +1,10 @@ +import {getOSAndName as libGetOSAndName} from 'expensify-common/lib/Device'; +import GetOSAndName from './types'; + +const getOSAndName: GetOSAndName = () => { + // eslint-disable-next-line @typescript-eslint/naming-convention + const {device_name, os_version} = libGetOSAndName(); + // eslint-disable-next-line @typescript-eslint/naming-convention + return {device_name, os_version}; +}; +export default getOSAndName; From 7786995f9a6390062b35cd3cff3f3f6fe25445ad Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Fri, 22 Sep 2023 12:54:14 +0200 Subject: [PATCH 3/3] Update comments --- .../actions/Device/getDeviceInfo/getOSAndName/index.native.ts | 2 ++ src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts | 2 ++ src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.native.ts b/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.native.ts index 455487d056f2..bb9eb572570e 100644 --- a/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.native.ts +++ b/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.native.ts @@ -6,8 +6,10 @@ const getOSAndName: GetOSAndName = () => { const deviceName = RNDeviceInfo.getDeviceNameSync(); const prettyName = `${Str.UCFirst(RNDeviceInfo.getManufacturerSync() || '')} ${deviceName}`; return { + // Parameter names are predefined and we don't choose it here // eslint-disable-next-line @typescript-eslint/naming-convention device_name: RNDeviceInfo.isEmulatorSync() ? `Emulator - ${prettyName}` : prettyName, + // Parameter names are predefined and we don't choose it here // eslint-disable-next-line @typescript-eslint/naming-convention os_version: RNDeviceInfo.getSystemVersion(), }; diff --git a/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts b/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts index 5155fc07afb2..d63c2fedc51d 100644 --- a/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts +++ b/src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts @@ -2,8 +2,10 @@ import {getOSAndName as libGetOSAndName} from 'expensify-common/lib/Device'; import GetOSAndName from './types'; const getOSAndName: GetOSAndName = () => { + // Parameter names are predefined and we don't choose it here // eslint-disable-next-line @typescript-eslint/naming-convention const {device_name, os_version} = libGetOSAndName(); + // Parameter names are predefined and we don't choose it here // eslint-disable-next-line @typescript-eslint/naming-convention return {device_name, os_version}; }; diff --git a/src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts b/src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts index 6616a13d8d23..2ca67c3c59c3 100644 --- a/src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts +++ b/src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts @@ -1,4 +1,4 @@ -// to keep same behavior from before migration +// Parameter names are predefined and we don't choose it here // eslint-disable-next-line @typescript-eslint/naming-convention type GetOSAndName = () => {device_name: string | undefined; os_version: string | undefined}; export default GetOSAndName;