hperrin / svelte-material-ui

Svelte Material UI Components
https://sveltematerialui.com/
Apache License 2.0
3.31k stars 285 forks source link

Type error from `@smui/menu` #622

Closed tuckergordon closed 9 months ago

tuckergordon commented 1 year ago

Describe the bug There is a type error stemming from @smui/menu. I actually ran into it while using @smui/select. You can see this error in this simple stackblitz

/home/projects/sveltejs-kit-template-default-egyygs/node_modules/@smui/menu/src/SelectionGroupIcon.ts:8:3
Error: Types of construct signatures are incompatible.
  Type 'new (options: ComponentConstructorOptions<{ getElement?: (() => HTMLSpanElement) | undefined; use?: ActionArray | undefined; class?: string | undefined; slot?: string | null | undefined; style?: string | ... 1 more ... | undefined; ... 198 more ...; 'on:fullscreenerror'?: EventHandler<...> | ... 1 more ... | undefined; }>) => Graphic__SvelteComponent_' is not assignable to type 'new <Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any>(options: ComponentConstructorOptions<Props>) => SvelteComponent<...>'.
    Construct signature return types 'Graphic__SvelteComponent_' and 'SvelteComponent<Props, Events, Slots>' are incompatible.
      The types of '$$prop_def' are incompatible between these types.
        Type '{ getElement?: (() => HTMLSpanElement) | undefined; use?: ActionArray | undefined; class?: string | undefined; slot?: string | null | undefined; style?: string | ... 1 more ... | undefined; ... 198 more ...; 'on:fullscreenerror'?: EventHandler<...> | ... 1 more ... | undefined; }' is not assignable to type 'Props'.
          '{ getElement?: (() => HTMLSpanElement) | undefined; use?: ActionArray | undefined; class?: string | undefined; slot?: string | null | undefined; style?: string | ... 1 more ... | undefined; ... 198 more ...; 'on:fullscreenerror'?: EventHandler<...> | ... 1 more ... | undefined; }' is assignable to the constraint of type 'Props', but 'Props' could be instantiated with a different subtype of constraint 'Record<string, any>'. 
  class: 'mdc-menu__selection-group-icon',
  component: Graphic,
});

To Reproduce Steps to reproduce the behavior:

  1. npm i -D @smui/select
  2. Import @smui/select into a component
  3. npm run check to run svelte-check

Additional context Looks like this showed up in #610 but didn't get resolved as part of #609

locus2k commented 1 year ago

I too am getting the same issue in 7.0.0-beta.15

vhscom commented 1 year ago

Pinned and backed down to several other beta versions 14, 13, 12 and 11, then down to beta.0 and all throw the same error. Given this error did not exist in beta.0 and @sveltejs/kit@1.0.1 it seems this is some kind of corner case. Given it's common to run svelte-check as a CI trigger I hope to see a workaround for this if the fix isn't immediately obvious.

vhscom commented 12 months ago

Possible root cause: https://github.com/sveltejs/language-tools/issues/1056

cabreraalex commented 11 months ago

Any way round this?

hperrin commented 9 months ago

This is fixed in 7.0.0-beta.16! (Along with some other TS issues.)