Skip to content

refactor(ui): update Theme type to use template literal type - #538

Open
pavel-rakhmanov wants to merge 1 commit into
ton-connect:mainfrom
pavel-rakhmanov:patch-1
Open

refactor(ui): update Theme type to use template literal type#538
pavel-rakhmanov wants to merge 1 commit into
ton-connect:mainfrom
pavel-rakhmanov:patch-1

Conversation

@pavel-rakhmanov

Copy link
Copy Markdown
Contributor

Without this change, the following code, despite being fully valid, will not pass TypeScript validation:

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 the use of the values of the THEME enum without causing any regression.

This change will allow us to configure the ton connect UI theme with a value from the app theme, matching the value that ton connect uses, without mapping the app value to the ton connect THEME enum. Also, it will allow to just use strings (with IDE auto completion and TS checks) without the need to import THEME enum

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
@pavel-rakhmanov
pavel-rakhmanov requested a review from a team as a code owner April 20, 2026 08:51
@vercel

vercel Bot commented Apr 20, 2026

Copy link
Copy Markdown

@pavel-rakhmanov is attempting to deploy a commit to the TOP Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant