From 8dcba1016fb35133911c28b5879874039204511b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 21 Aug 2023 14:34:17 +0200 Subject: [PATCH] Improve the typing of the browser/platform identifiers --- ts/WoltLabSuite/Core/Environment.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ts/WoltLabSuite/Core/Environment.ts b/ts/WoltLabSuite/Core/Environment.ts index d3e4f190bf..5700654a5b 100644 --- a/ts/WoltLabSuite/Core/Environment.ts +++ b/ts/WoltLabSuite/Core/Environment.ts @@ -6,8 +6,11 @@ * @license GNU Lesser General Public License */ -let _browser = "other"; -let _platform = "desktop"; +type Browser = "chrome" | "firefox" | "microsoft" | "other" | "safari"; +type Platform = "android" | "desktop" | "ios" | "mobile" | "windows"; + +let _browser: Browser = "other"; +let _platform: Platform = "desktop"; let _touch = false; /** @@ -72,7 +75,7 @@ export function setup(): void { * - microsoft: Internet Explorer and Microsoft Edge * - safari */ -export function browser(): string { +export function browser(): Browser { return _browser; } @@ -85,7 +88,7 @@ export function browser(): string { * - ios: iPhone, iPad and iPod * - windows: Windows on phones/tablets */ -export function platform(): string { +export function platform(): Platform { return _platform; } -- 2.20.1