endigma / unocss-preset-radix

A preset for UnoCSS to let you use Radix color palette
https://endigma.github.io/unocss-preset-radix/
MIT License
32 stars 6 forks source link

Typescript error with docs config #10

Closed silveltman closed 1 year ago

silveltman commented 1 year ago

I use the exact same config as the readme/docs show and immediately get the following typescript error:

Type 'Preset<{}>' is not assignable to type 'Preset<Theme> | Preset<Theme>[]'.
  Type 'Preset<{}>' is not assignable to type 'Preset<Theme>'.
    Types of property 'rules' are incompatible.
      Type 'Rule<{}>[] | undefined' is not assignable to type 'Rule<Theme>[] | undefined'.
        Type 'Rule<{}>[]' is not assignable to type 'Rule<Theme>[]'.
          Type 'Rule<{}>' is not assignable to type 'Rule<Theme>'.
            Type '[RegExp, DynamicMatcher<{}>]' is not assignable to type 'Rule<Theme>'.
              Type '[RegExp, DynamicMatcher<{}>]' is not assignable to type '[string, CSSObject | CSSEntries] | [RegExp, DynamicMatcher<Theme>]'.
                Type '[RegExp, DynamicMatcher<{}>]' is not assignable to type '[string, CSSObject | CSSEntries]'.
                  Type at position 0 in source is not compatible with type at position 0 in target.
                    Type 'RegExp' is not assignable to type 'string'.ts(2322)
(alias) presetRadix(options: PresetRadixOptions): Preset<{}>
import presetRadix

uno.config.ts:

import { defineConfig, presetUno } from 'unocss';
import { presetRadix } from 'unocss-preset-radix';

export default defineConfig({
    presets: [
        presetUno(),
        presetRadix({
            palette: ['blue', 'green', 'red'],
            aliases: {
                primary: 'green',
                base: 'slate'
            }
        })
    ]
});
endigma commented 1 year ago

Yep, I've known of this one for a while, it's pretty intermittent. I don't think it affects usage though, so it's not my top priority. I'll try to find time to look into this soon.

micisse commented 1 year ago

Hi, i had the same problem

@endigma i created this PR to fix this issue https://github.com/endigma/unocss-preset-radix/pull/14

@silveltman You can use this correction until the PR is merged if you still encounter the same problem.

// uno.config.ts
import { Preset } from "unocss"
import type { Theme } from "unocss/preset-uno"
...
presetRadix({
    /* options */
}) as unknown as Preset<Theme>,
silveltman commented 1 year ago

I see the PR in merged, but 2.5.3 is not yet available on npm. 2.5.1 is max.

Just in case wanted to let you know ✌️

endigma commented 1 year ago

Sorry, don't really have a great flow for publishing packages. Should be up now. I'd accept a Github Actions PR :)