Skip to content

mount() function does not appear to properly handle passed prop types #16549

@jhobz

Description

@jhobz

Describe the bug

The mount() function will provide a type error in VS Code when passing any props within the object of the "props" field. Running latest version of the Svelte extension and library (5.37.3). Note that the error changes depending on what type of prop you try to pass. The log below is from including two props: a string and a Snippet.

No overload matches this call.
  Overload 1 of 3, '(component: ComponentType<SvelteComponent<Props, any, any>> | Component<Props, {}, any>, options: MountOptions<Props>): {}', gave the following error.
    Type 'Snippet<[]> | undefined' is not assignable to type 'Snippet<[]>'.
      Type 'undefined' is not assignable to type 'Snippet<[]>'.
  Overload 2 of 3, '(component: ComponentType<SvelteComponent<Props, any, any>> | Component<Props, {}, any>, options: MountOptions<Props>): {}', gave the following error.
    Type 'Snippet<[]> | undefined' is not assignable to type 'Snippet<[]>'.
      Type 'undefined' is not assignable to type 'Snippet<[]>'.
  Overload 3 of 3, '(component: ComponentType<SvelteComponent<Props, any, any>> | Component<Props, {}, any>, options: MountOptions<Props>): {}', gave the following error.
    Type 'Snippet<[]> | undefined' is not assignable to type 'Snippet<[]>'.
      Type 'undefined' is not assignable to type 'Snippet<[]>'.ts(2769)

Reproduction

This REPL does not produce an error in the online playground, but does in VS Code. If you remove the passed Snippet prop but keep the string one, you should get a different error.

https://svelte.dev/playground/0efbc0a75afd42199c5acbd70854a37f?version=5.37.3

Logs

No overload matches this call.
  Overload 1 of 3, '(component: ComponentType<SvelteComponent<Props, any, any>> | Component<Props, {}, any>, options: MountOptions<Props>): {}', gave the following error.
    Type 'Snippet<[]> | undefined' is not assignable to type 'Snippet<[]>'.
      Type 'undefined' is not assignable to type 'Snippet<[]>'.
  Overload 2 of 3, '(component: ComponentType<SvelteComponent<Props, any, any>> | Component<Props, {}, any>, options: MountOptions<Props>): {}', gave the following error.
    Type 'Snippet<[]> | undefined' is not assignable to type 'Snippet<[]>'.
      Type 'undefined' is not assignable to type 'Snippet<[]>'.
  Overload 3 of 3, '(component: ComponentType<SvelteComponent<Props, any, any>> | Component<Props, {}, any>, options: MountOptions<Props>): {}', gave the following error.
    Type 'Snippet<[]> | undefined' is not assignable to type 'Snippet<[]>'.
      Type 'undefined' is not assignable to type 'Snippet<[]>'.ts(2769)

System Info

'envinfo' is not recognized as an internal or external command,
operable program or batch file.

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions