Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(type): theme field autocompletion #449

Merged
merged 1 commit into from
Mar 30, 2023
Merged

Conversation

vaakian
Copy link
Contributor

@vaakian vaakian commented Mar 25, 2023

It's suffering without autocompletion when trying to use built-in themes. But I noticed that the code has already attempted to provide it but it stoped working on TypeScript version >= 4.7.4.

I've tested different approaches, here's the playground demo, and finally decided to use the empty interface solution.

Before:

image

After:

image

@netlify
Copy link

netlify bot commented Mar 25, 2023

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit c3c16da
🔍 Latest deploy log https://app.netlify.com/sites/shiki-matsu/deploys/641ea64b0d15100008b8e14c
😎 Deploy Preview https://deploy-preview-449--shiki-matsu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@vaakian vaakian changed the title fix(type): theme field autocompletion fix(type): theme field autocompletion Mar 25, 2023
@@ -193,12 +193,14 @@ export interface IShikiTheme extends IRawTheme {
colors?: Record<string, string>
}

interface Nothing {}
Copy link
Contributor

@LeoDog896 LeoDog896 Mar 28, 2023

Choose a reason for hiding this comment

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

LGTM! My only suggestion is to document what this utility type is for. Afaik, the reason why this works is that T is the primary completion, while U is provided as a fallback by unionizing it with a type that can never be used but doesn't error out. Otherwise, that is fully optional (seems self-documenting) and the contribution is great!

@orta
Copy link
Contributor

orta commented Mar 30, 2023

Yeah, looks good to me, nice switch with the interface 👍🏻

@orta orta merged commit 99a9a3d into shikijs:main Mar 30, 2023
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.

Config autocompletion of theme field
3 participants