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

Fix type of component prop of Route #250

Merged
merged 1 commit into from
Jul 25, 2023

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.

None yet

2 participants