dasDaniel / svelte-table

A svelte table implementation that allows sorting and filtering
https://dasdaniel.github.io/svelte-table/
MIT License
535 stars 40 forks source link

Argument of type 'typeof (Anonymous class)' is not assignable to parameter of type 'ConstructorOfATypedSvelteComponent' #117

Closed ianengelbrecht closed 2 years ago

ianengelbrecht commented 2 years ago

With the latest version of svelte (3.52) I get this error when importing SvelteTable

image

dasDaniel commented 2 years ago

tested with 3.52.0 and 3.53.1 and cannot reproduce. Can you provide an example repo?

The error you are showing seems to me like it is related to typescript. But your script definition does not indicate a ts file

Do you see the error still if you switch to <script lang="ts">?

I tried setting up a new sveltekit project from scratch and adding svelte-table. I did see one issue in vs-code, which was Could not find a declaration file for module 'svelte-table' Looks like this is happening because svelte is trying to pull the umd module whereas, to my knowledge anyway, it should be trying to get the svelte entry from the package. I set it to import SvelteTable from "svelte-table/src/SvelteTable.svelte" that and that error went away. Though not the same error, maybe you could try that too.

ianengelbrecht commented 2 years ago

Repo showing this problem is set up at https://github.com/ianengelbrecht/svelte-playground

This is the raw svelte starter project, with svelte-table added, nothing else. Commands to create it were:

cd svelte-playground
npm install
npm install svelte-table

Then in App.svelte:

import SvelteTable from "svelte-table";

...and include <SvelteTable /> on line 9.

I hope that helps. I tried <script lang="ts"> but no effect.

dasDaniel commented 2 years ago

Thanks for the example. Looks like it can be resolved the same way.

import SvelteTable from "svelte-table/src/SvelteTable.svelte";

this is because in the package.json the main parameter is set to dist/umd/SvelteTable.js and the vite setup is using the main instead of the svelte path. Switching it to main in the library would resolve the issue for you, but I'm going to hold off on that change until I can understand better what the impact of that change would be.

ianengelbrecht commented 2 years ago

Perfecto, thanks @dasDaniel, I'll leave closing the issue to you then when you're happy to do so.