refactor(ui): update Theme type to use template literal type - #538
Open
pavel-rakhmanov wants to merge 1 commit into
Open
refactor(ui): update Theme type to use template literal type#538pavel-rakhmanov wants to merge 1 commit into
pavel-rakhmanov wants to merge 1 commit into
Conversation
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 is attempting to deploy a commit to the TOP Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Without this change, the following code, despite being fully valid, will not pass TypeScript validation:
By declaring the
Themetype via a string literal derived from theTHEMEenum values, the code above will pass TypeScript checks.This change will still allow the use of the values of the
THEMEenum 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
THEMEenum. Also, it will allow to just use strings (with IDE auto completion and TS checks) without the need to importTHEMEenum