Skip to content

Conversation

@tpambor
Copy link
Contributor

@tpambor tpambor commented Jul 25, 2023

Assigning any component to a route using Svelte 4

<Router>
  <Route component={ Info } />
</Router>

results in a typescript error

Error: Type 'typeof Info__SvelteComponent_' is not assignable to type 'typeof SvelteComponent | AsyncSvelteComponent'.
  Type 'typeof Info__SvelteComponent_' is not assignable to type 'typeof SvelteComponent'.
    Types of construct signatures are incompatible.
      Type 'new (options: ComponentConstructorOptions<Record<string, never>>) => Info__SvelteComponent_' is not assignable to type 'new <Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any>(options: ComponentConstructorOptions<Props>) => SvelteComponent<...>'.
        Types of parameters 'options' and 'options' are incompatible.
          Type 'ComponentConstructorOptions<Props>' is not assignable to type 'ComponentConstructorOptions<Record<string, never>>'.
            Type 'Props' is not assignable to type 'Record<string, never>'.
              Type 'Record<string, any>' is not assignable to type 'Record<string, never>'.
                'string' index signatures are incompatible.
                  Type 'any' is not assignable to type 'never'. (ts)

SvelteComponent in Svelte 4 behaves as SvelteComponenTyped and therefore <any> should be added to typeof SvelteComponent. For more details see sveltejs/svelte#8512.

@krishnaTORQUE krishnaTORQUE merged commit ab627c2 into EmilTholin:master Jul 25, 2023
@krishnaTORQUE
Copy link
Collaborator

Thanks for PR

krishnaTORQUE added a commit that referenced this pull request Jul 25, 2023
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