From eac023dd8ebbe8d5b7d166e8be14a0246e64dff3 Mon Sep 17 00:00:00 2001 From: Pavel Rakhmanov Date: Mon, 20 Apr 2026 10:50:16 +0200 Subject: [PATCH] refactor(ui): update Theme type to use template literal type Without this change, the following code, despice being fully valid, will not pass TypeScript validation: ```ts new TonConnectUI({ uiPreferences: { theme: 'DARK' // ^ Type '"DARK"' is not assignable to type 'Theme | undefined'. } }) ``` By declaring the `Theme` type via a string literal derived from the `THEME` enum values, the code above will pass TypeScript checks. This change will still allow usage of the values of the `THEME` enum without any regression. This change will allow us to configure the ton connect ui theme with a value from the app theme if it matches the value that ton connect uses without the need to map the app value to the ton connect `THEME` enum value. Also, it will allow to just use strings (with IDE auto completion and TS checks) without the need to import `THEME` enum --- packages/ui/src/models/THEME.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/src/models/THEME.ts b/packages/ui/src/models/THEME.ts index f562dfcf8..64c70e6e9 100644 --- a/packages/ui/src/models/THEME.ts +++ b/packages/ui/src/models/THEME.ts @@ -3,4 +3,4 @@ export enum THEME { LIGHT = 'LIGHT' } -export type Theme = THEME | 'SYSTEM'; +export type Theme = `${THEME}` | 'SYSTEM';