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

feat: expose theme type var #1394

Closed
wants to merge 35 commits into from
Closed

feat: expose theme type var #1394

wants to merge 35 commits into from

Conversation

equt
Copy link
Contributor

@equt equt commented Aug 9, 2022

This PR takes a try to type Theme in all official packages correctly, instead of omitting it or setting it to any.

c.c. This should close #1270, and previous related PR #1002, #1003

Attentions Required

  1. Currently, I type all themes as T, neither T extends {} nor T extends Record<string, unknown>, as this kind of restriction doesn't make any sense to me.
  2. CI is broken, as there're several decisions that have to be made
  3. Currently, @unocss/preset-uno is the default preset, this means we cannot type the them e as a generic. The below code is theoretically not correct.
    export default function UnocssVitePlugin<Theme extends {}>(
    configOrPath?: VitePluginConfig<Theme> | string,
    ): Plugin[] {
    return VitePlugin(
    configOrPath,
    {
    presets: [
    presetUno(),
    ],
    },
    )
    }

@netlify
Copy link

netlify bot commented Aug 9, 2022

Deploy Preview for unocss ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit bc50a65
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/62f4bfca23472a0008174e67
😎 Deploy Preview https://deploy-preview-1394--unocss.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.

@equt equt marked this pull request as draft August 9, 2022 02:14
@equt equt marked this pull request as ready for review August 10, 2022 07:33
@antfu
Copy link
Member

antfu commented Aug 10, 2022

Maybe we should keep more expressive Theme instead of T

@equt
Copy link
Contributor Author

equt commented Aug 10, 2022

I'm open to that. Without restriction provides more flexibility, and maybe some people are comfortable with that. I would suggest extracting the Theme interface to a standalone package then.

@equt
Copy link
Contributor Author

equt commented Aug 11, 2022

@antfu is it ok to have the restriction that all themes should always extend the Theme exported from preset-mini?

(sorry for the ping, as I'd like to merge/close the PR ASAP since it has to involve all packages)

@stale
Copy link

stale bot commented Oct 10, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 10, 2022
@stale stale bot closed this Oct 17, 2022
@smashercosmo
Copy link

Any plans to resurrect this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need useful types from the theme object
3 participants