konstaui / konsta

Mobile UI components made with Tailwind CSS
https://konstaui.com
MIT License
3.55k stars 131 forks source link

Svelte Typescript ConstructorOfATypedSvelteComponent error #151

Closed xdubx closed 1 year ago

xdubx commented 1 year ago

Check that this is really a bug

Reproduction link

https://stackblitz.com/edit/konsta-svelte?file=App.svelte

Bug description

VS Code fires error only in Editor. Build works fine.

Argument of type 'typeof Page' is not assignable to parameter of type 'ConstructorOfATypedSvelteComponent'.
  Types of construct signatures are incompatible.
    Type 'new (options: ComponentConstructorOptions<any>) => Page' is not assignable to type 'new (args: { target: any; props?: any; }) => ATypedSvelteComponent'.
      Construct signature return types 'Page' and 'ATypedSvelteComponent' are incompatible.
        The types of '$on' are incompatible between these types.
          Type '<K extends never>(type: K, callback: (e: {}[K]) => void) => () => void' is not assignable to type '(event: string, handler: ((e: any) => any) | null | undefined) => () => void'.
            Types of parameters 'callback' and 'handler' are incompatible.
              Type '((e: any) => any) | null | undefined' is not assignable to type '(e: never) => void'.
                Type 'undefined' is not assignable to type '(e: never) => void'.

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)

Expected Behavior

No response

Actual Behavior

No response

Konsta UI version

2.0.0

Platform/Target and Browser Versions

Linux

Validations

Would you like to open a PR for this bug?

iva2k commented 10 months ago

This same error is flagged by svelte-check --tsconfig ./tsconfig.json (tried in Svelte 5.0.0-next.28)