Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How to avoid "Typed Svelte Components" on svelte, using Typescript

$
0
0

In a simple, very simple svelte (Not Svelte Kit) app, using Typescript, VSCode is giving me this error in "Router" and "Route" classes of svelte-routing:

CODE:

<script lang="ts">import {    Router,    Route,    Link} from 'svelte-routing';const url = "";</script><Router on:route> // ERROR HERE<Route path=""> // ERROR HERE<span>"other"</span></Route></Router>

ERROR:

Argument of type 'typeof Router' is not assignable to parameter oftype 'ConstructorOfATypedSvelteComponent'. Type 'typeof Router'provides no match for the signature 'new (args: { target: any; props?:any; }): ATypedSvelteComponent'.

Possible causes:

You use the instance type of a component where you should use the constructor type Type >definitions are missing for this Svelte Component.

If you are using Svelte 3.31+, >use SvelteComponentTyped to add a definition:import type { SvelteComponentTyped } from "svelte";class ComponentName extends SvelteComponentTyped<{propertyName: string;}> {}ts(2345)

This works for me using Native JS but not with typescript.

I do not know if there is a incompatibility with Svelte and Typescript, Svelte-Routing module and typescript, or I'm doing something wrong.

Thanks everyone.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>