Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

ThemeRegistration type isn't compatible with VS Code theme schema #63

Closed
gdomingu opened this issue Dec 27, 2023 · 4 comments
Closed

ThemeRegistration type isn't compatible with VS Code theme schema #63

gdomingu opened this issue Dec 27, 2023 · 4 comments

Comments

@gdomingu
Copy link

Hi there,

I noticed that the ThemeRegistration type isn't compatible with the shape of the schema when one exports a current theme via VS Code.

$schema: 'vscode://schemas/color-theme',

ThemeRegistration seems to expect attributes name, bg, fg, and settings. All which don't appear in the vscode://schemas/color-theme schema. Wondering if there is a different type I should use that corresponds better with the vs code schema?

Everything works as expected when I pass in the theme JSON, but I would like to declare the correct type instead of just using any in typescript.

Thank you.

@antfu
Copy link
Owner

antfu commented Dec 27, 2023

Most of them are not required. TextMeta theme does not usually care about background and default foreground color; colors are for VS-Code-specific colors (the color of panels, borders etc); name and displayName are just metadata; When bg and fg are not provided, we will try to look from settings, otherwise will fallback to default value. The other types are there to be compatible with other integrations but are not used by Shikiji itself.

@gdomingu
Copy link
Author

gdomingu commented Dec 27, 2023

Here is an example of the type error.

is missing the following properties from type 'ThemeRegistration': name, settings, fg, bg ts(2739)

Image of type error

If name and displayName are just metadata and bg and fg have fallbacks could we mark those properties as optional in the shikiji type?

@antfu
Copy link
Owner

antfu commented Dec 27, 2023

You should use ThemeRegistrationRaw for that

@gdomingu
Copy link
Author

gdomingu commented Dec 27, 2023

It doesn't look like ThemeRegistrationRaw has properties type, $schema, or colors.

Image of error for ThemeRegistrationRaw

@antfu antfu closed this as completed in 03d13ba Dec 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants