Skip to content

fix(type): theme field autocompletion#449

Merged
orta merged 1 commit into
shikijs:mainfrom
vaakian:fix/autocompletion
Mar 30, 2023
Merged

fix(type): theme field autocompletion#449
orta merged 1 commit into
shikijs:mainfrom
vaakian:fix/autocompletion

Conversation

@vaakian

@vaakian vaakian commented Mar 25, 2023

Copy link
Copy Markdown
Contributor

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

netlify Bot commented Mar 25, 2023

Copy link
Copy Markdown

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
colors?: Record<string, string>
}

interface Nothing {}

@tristan-f-r tristan-f-r Mar 28, 2023

Copy link
Copy Markdown
Contributor

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

orta commented Mar 30, 2023

Copy link
Copy Markdown
Contributor

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

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