Skip to content

Conversation

@jasonlyu123
Copy link
Member

For the new transformation. Currently, it would show an error with a component having events in the typedef. For example:

class Component extends SvelteComponentTyped<{}, { click: MouseEvent }, {}>{}

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

For my future self, this is the error that would appear:

Argument of type 'typeof Works2' is not assignable to parameter of type 'new (args: { target: any; props?: any; }) => Svelte2TsxComponent<any, any, any>'.
  Types of construct signatures are incompatible.
    Type 'new (options: IComponentOptions<{ hi: string; }>) => Works2' is not assignable to type 'new (args: { target: any; props?: any; }) => Svelte2TsxComponent<any, any, any>'.
      Construct signature return types 'Works2' and 'Svelte2TsxComponent<any, any, any>' are incompatible.
        The types of '$on' are incompatible between these types.
          Type '<K extends "click">(type: K, callback: (e: { click: MouseEvent; }[K]) => void) => () => void' is not assignable to type '<K extends string>(event: K, handler: (e: any) => any) => () => void'.
            Types of parameters 'type' and 'event' are incompatible.
              Type 'K' is not assignable to type '"click"'.
                Type 'string' is not assignable to type '"click"'.(2345)

@dummdidumm dummdidumm merged commit 1f4a22e into sveltejs:master Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants