chore(env-utils): narrow down types of is platform functions

This commit is contained in:
Jiri Zbytovsky
2025-03-20 09:06:39 +01:00
committed by Jiri Zbytovsky
parent 5f431c0d01
commit 35c943abd9
2 changed files with 6 additions and 6 deletions

View File

@@ -71,14 +71,14 @@ const getProcessPlatform = () => (typeof process !== 'undefined' ? process.platf
const isMacOs = () => {
if (getProcessPlatform() === 'darwin') return true;
if (typeof window === 'undefined') return;
if (typeof window === 'undefined') return false;
return getPlatform().toLowerCase().startsWith('mac');
};
const isWindows = () => {
if (getProcessPlatform() === 'win32') return true;
if (typeof window === 'undefined') return;
if (typeof window === 'undefined') return false;
return getPlatform().toLowerCase().startsWith('win');
};
@@ -87,7 +87,7 @@ const isIOs = () => ['iPhone', 'iPad', 'iPod'].includes(getPlatform());
const isLinux = () => {
if (getProcessPlatform() === 'linux') return true;
if (typeof window === 'undefined') return;
if (typeof window === 'undefined') return false;
// exclude Android and Chrome OS as window.navigator.platform of those OS is Linux
if (isAndroid() || isChromeOs()) return false;

View File

@@ -24,10 +24,10 @@ export interface EnvUtils {
getLocationOrigin: () => string;
getLocationHostname: () => string;
getProcessPlatform: () => string;
isMacOs: () => boolean | undefined;
isWindows: () => boolean | undefined;
isMacOs: () => boolean;
isWindows: () => boolean;
isIOs: () => boolean;
isLinux: () => boolean | undefined;
isLinux: () => boolean;
isCodesignBuild: () => boolean;
getOsName: () => '' | 'android' | 'linux' | 'windows' | 'macos' | 'chromeos' | 'ios';
getOsNameWeb: () => string | undefined;