Skip to content

Commit

Permalink
Merge pull request #27534 from software-mansion-labs/ts-migration/kow…
Browse files Browse the repository at this point in the history
…czarz/get-os-and-name

[No QA][TS migration] Migrate 'getOSAndName' lib to TypeScript
  • Loading branch information
madmax330 authored Sep 26, 2023
2 parents 52c3f53 + 24bf332 commit 3402597
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/libs/actions/Device/getDeviceInfo/getOSAndName/index.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
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 {
// 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(),
};
}
};

export default getOSAndName;
12 changes: 12 additions & 0 deletions src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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};
};
export default getOSAndName;
4 changes: 4 additions & 0 deletions src/libs/actions/Device/getDeviceInfo/getOSAndName/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// 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;

0 comments on commit 3402597

Please sign in to comment.