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

Error with component typedef doesn't have event #1767

Closed
jasonlyu123 opened this issue Dec 9, 2022 · 3 comments
Closed

Error with component typedef doesn't have event #1767

jasonlyu123 opened this issue Dec 9, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@jasonlyu123
Copy link
Member

jasonlyu123 commented Dec 9, 2022

Describe the bug

There'll be a type check error when the Component type definition extends SvelteCopmonentTyped<{}, {}, {}> in strict mode. Not sure if we should count it as a bug because it's possible to avoid it in the userland.

The error is

Argument of type 'typeof Component' is not assignable to parameter of type 'ConstructorOfATypedSvelteComponent'.
  Types of construct signatures are incompatible.
    Type 'new (options: IComponentOptions<{}>) => Component' is not assignable to type 'new (args: { target: any; props?: any; }) => ATypedSvelteComponent'.
      Construct signature return types 'Component' 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'.
...

Reproduction

<script lang="ts">
    import { SvelteComponentTyped } from "svelte";

    class Component extends SvelteComponentTyped<{}, {}, {}>{}
</script>

<Component></Component>

Expected behaviour

no error.

System Info

  • OS: Windows
  • IDE: VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

@jasonlyu123 jasonlyu123 added the bug Something isn't working label Dec 9, 2022
@dummdidumm
Copy link
Member

dummdidumm commented Dec 9, 2022

I can't reproduce only with earlier versions of Svelte that had the | undefined | null missing. I'm not sure what we can do about this except say "bump your Svelte version".

@jasonlyu123
Copy link
Member Author

Yeah. Indeed it doesn't happen in the latest svelte version That was weird. I thought I am crazy when I can't reproduce it in the typescript playground. So we fixed it with some unrelated changes 😆. Still worth the effort for the visibility.

@jasonlyu123
Copy link
Member Author

jasonlyu123 commented Feb 6, 2023

Closing since svelte-check now requires a later version that doesn't have this problem. If anyone encounter this you can update svelte to 3.51 or later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants