Skip to content

Comments

INSTUI-4842 [v12] better typing for themes#2223

Merged
matyasf merged 1 commit intov12from
more_theme_typing
Nov 3, 2025
Merged

INSTUI-4842 [v12] better typing for themes#2223
matyasf merged 1 commit intov12from
more_theme_typing

Conversation

@matyasf
Copy link
Collaborator

@matyasf matyasf commented Oct 31, 2025

  • Use types from Token studio from typing their converted JSONs instead of types from semantics/primitives
  • Add some simple typing for the whole theme object

To test:
run build:themes and check out the generated code (especially the types) in ui-themes/src/themes/newThemes

@matyasf matyasf self-assigned this Oct 31, 2025
@matyasf matyasf changed the base branch from master to v12 October 31, 2025 14:59
@CLAassistant
Copy link

CLAassistant commented Oct 31, 2025

CLA assistant check
All committers have signed the CLA.

Comment on lines +92 to +93
// the following types are coming from SingleXYToken in @token-studio/types
// we could add them as imports from @token-studio/types if needed
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to just hardcode these simple types here, because importing them all if they are required would be lots of extra code

Comment on lines +144 to +153
if (componentTypes.includes('TokenBoxshadowValueInst')) {
importBoxShadow = `import type { TokenBoxshadowValueInst } from '../commonTypes'`
}
let importBorder = ''
if (componentTypes.includes('TokenBorderValue')) {
importBorder = `import type { TokenBorderValue } from '@tokens-studio/types'`
}
let importTypography = ''
if (componentTypes.includes('TokenTypographyValueInst')) {
importTypography = `import type { TokenTypographyValueInst } from '../commonTypes'`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit ugly, but simple. If we want we can make this nicer and dynamic, IMO its not needed because I dont expect Token Studio to change its types often

@github-actions
Copy link

github-actions bot commented Oct 31, 2025

PR Preview Action v1.6.2
Preview removed because the pull request was closed.
2025-11-03 10:53 UTC

Comment on lines +273 to +276
export type BaseTheme<P extends Record<string, any>, S extends Record<string, any>> = {
primitives: P
semantics: S
components: ComponentTypes
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type will likely change in the future, the structure of primitives and semantics is fixed

it uses now types from Token Studio
@matyasf matyasf changed the title [v12] better typing for themes INSTUI-4842 [v12] better typing for themes Oct 31, 2025
params: StyleParams,
//TODO type themes properly
theme: any
theme: any // TODO BaseTheme is is not good, it accesses theme.semantics.spacing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the new theme already. I'm not sure what you mean about BaseTheme being not good. Can you elaborate?

Also typo (is is)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured out what you meant. This theme should be the whole new theme in time, but as of right now, any will be enough

@matyasf matyasf merged commit 3b3a3a1 into v12 Nov 3, 2025
6 of 7 checks passed
@matyasf matyasf deleted the more_theme_typing branch November 3, 2025 10:52
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.

4 participants