Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA][TS migration] Migrate 'getOSAndName' lib to TypeScript #27534

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
kowczarz marked this conversation as resolved.
Show resolved Hide resolved
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
kowczarz marked this conversation as resolved.
Show resolved Hide resolved
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
kowczarz marked this conversation as resolved.
Show resolved Hide resolved
type GetOSAndName = () => {device_name: string | undefined; os_version: string | undefined};
export default GetOSAndName;
Loading