huntabyte / cmdk-sv

cmdk, but for Svelte ✨
https://cmdk-sv.com
MIT License
423 stars 18 forks source link

Component type error #24

Closed Not-Jayden closed 8 months ago

Not-Jayden commented 8 months ago

Hey, keen to try this package out.

I'm getting the following error when using Command anywhere in the Svelte markup.

Argument of type 'typeof Command' is not assignable to parameter of type 'ConstructorOfATypedSvelteComponent'.
  Type 'typeof Command' provides no match for the signature 'new (args: { target: any; props?: any; }): ATypedSvelteComponent'.

Possible causes:
- You use the instance type of a component where you should use the constructor type
- Type definitions are missing for this Svelte Component. If you are using Svelte 3.31+, use SvelteComponentTyped to add a definition:
  import type { SvelteComponentTyped } from "svelte";
  class ComponentName extends SvelteComponentTyped<{propertyName: string;}> {}ts(2345)

I suspect this is a config issue on my end, but if you have any ideas as to how I can resolve would be much appreciated.

This is the component for reference, copied from the readme.

  <script lang="ts">
    import {Command} from 'cmdk-sv';
</script>

<CommandRoot label="Command Menu">
    <Command.Input />
    <Command.List>
        <Command.Empty>No results found.</Command.Empty>

        <Command.Group heading="Letters">
            <Command.Item>a</Command.Item>
            <Command.Item>b</Command.Item>
            <Command.Separator />
            <Command.Item>c</Command.Item>
        </Command.Group>

        <Command.Item>Apple</Command.Item>
    </Command.List>
</CommandRoot>
Not-Jayden commented 8 months ago

Figured it out I think. My app was still using Svelte 3 to my surprise, so I don't think the component typings were compatible.