ItalyPaleAle / svelte-spa-router

Router for SPAs using Svelte 3
MIT License
1.55k stars 106 forks source link

TS Type mismatch for components #329

Open BusschaertTanguy opened 3 days ago

BusschaertTanguy commented 3 days ago

Hello,

I just started a brand new svelte project in vite, and have a type mismatch when defining routes with wrap.

I'm using Svelte 5, so maybe that's related.

This is the setup

<script lang="ts">
    import Router from "svelte-spa-router";
    import wrap from "svelte-spa-router/wrap";

    const routes: RouteDefinition= {
        '/products/': wrap({
            asyncComponent: () => import('./pages/products/Products.svelte'), // Error on asyncComponent
        })
    }
</script>

<Router routes={routes} />

image

This also applies for normal route definitions

<script lang="ts">
    import Router, {type RouteDefinition} from "svelte-spa-router";
    import Products from "./pages/products/Products.svelte";

    const routes: RouteDefinition = {
        '/products/': Products // Error on '/products'
    }
</script>

<Router routes={routes} />

image

pjaudiomv commented 2 days ago

im having same issue

const routes = {
    '/login': Login,
    '/meetings': wrap({
      component: Meetings,
      conditions: [requiresAuthentication]
    }),
    '/formats': wrap({
      component: Formats,
      conditions: [requiresAuthenticationServerAdmin]
    }),
    '/servicebodies': wrap({
      component: ServiceBodies,
      conditions: [requiresAuthenticationAdmin]
    }),
    '/users': wrap({
      component: Users,
      conditions: [requiresAuthenticationAdmin]
    }),
    '/account': wrap({
      component: Account,
      conditions: [requiresAuthentication]
    }),
    '*': wrap({
      component: Home,
      conditions: [requiresAuthentication]
    })
  };
Screenshot 2024-10-26 at 10 07 36 AM
pjaudiomv commented 2 days ago

im using svelte 5 with vite and 4 compatibility mode

    svelte({
      compilerOptions: {
        compatibility: {
          componentApi: 4
        }
      }
    }),
carbogninalberto commented 2 days ago

Thanks for the issue. Tomorrow or Monday, I should have a couple of hours to open the PR for the Svelte5 support.

pjaudiomv commented 2 days ago

Great thanks