Consider adding TypeScript declarations for uppy Svelte package
It would be great to have that so svelte-check will not complain anymore and for more useful information that the TypeScript compiler can work with!
Currently I get:
Hint: Could not find a declaration file for module '@uppy/svelte'. '[...]/node_modules/@uppy/svelte/dist/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/uppy__svelte` if it exists or add a new declaration (.d.ts) file containing `declare module '@uppy/svelte';` (ts)
import { DashboardModal } from "@uppy/svelte"
Also I get errors when instantiating uppy, e.g. let uppy = new Uppy() yields the error
[ts 2350] [E] only a void function can be called with the 'new' keyword.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Nope
This would be very nice to have, is there currently a temp work around for this?
This is how I can use it for now, this should do as a workaround:
<script lang="ts">
import Dashboard from "@uppy/dashboard";
import Uppy from '@uppy/core';
// Idk if that css import is needed
import '@uppy/core/dist/style.css';
import '@uppy/dashboard/dist/style.css';
import { onMount } from "svelte";
onMount(()=>{
const uppy = new Uppy({id: "lalal", allowMultipleUploads:false,restrictions:{maxNumberOfFiles:1,maxFileSize:10000000,allowedFileTypes:[".pdf",".docx",".pptx",".html"]}});
uppy.use(Dashboard,{inline:true, target:"#dashboard"})
});
</script>
<main>
<div id="dashboard"></div>
</main>
EDIT: You do need to import the css files.
what a horrible workaround, the same issue of types happens with react
Note that we're done with the complete transition of the codebase to TS. It will be released soon under 4.0.0
Or use it today in the beta: https://www.npmjs.com/package/@uppy/svelte/v/4.0.0-beta.1
Or use it today in the beta: https://www.npmjs.com/package/@uppy/svelte/v/4.0.0-beta.1
I tried that but am getting Cannot read properties of undefined (reading 'id')
TypeError: Cannot read properties of undefined (reading 'id')
at Uppy.removePlugin (file:///Users/user/project/node_modules/@uppy/core/lib/Uppy.js:1031:42)
at uninstallPlugin (/Users/user/project/node_modules/@uppy/svelte/src/components/DragDrop.svelte:24:18)
at /Users/user/project/node_modules/@uppy/svelte/src/components/DragDrop.svelte:29:19
at run (/Users/user/project/node_modules/svelte/src/runtime/internal/utils.js:41:9)
at Array.forEach (<anonymous>)
at Module.run_all (/Users/user/project/node_modules/svelte/src/runtime/internal/utils.js:53:6)
at Object.render (/Users/user/project/node_modules/svelte/src/runtime/internal/ssr.js:165:4)
at Module.render_response (/Users/user/project/node_modules/@sveltejs/kit/src/runtime/server/page/render.js:171:29)
at async Module.render_page (/Users/user/project/node_modules/@sveltejs/kit/src/runtime/server/page/index.js:286:10)
at async resolve (/Users/user/project/node_modules/@sveltejs/kit/src/runtime/server/respond.js:446:18)
with
<script lang="ts">
import { DragDrop } from '@uppy/svelte';
import Uppy from '@uppy/core';
import '@uppy/core/dist/style.css';
import '@uppy/drag-drop/dist/style.css';
const uppy = new Uppy();
</script>
<DragDrop {uppy} />
@cellulosa fixed in https://github.com/transloadit/uppy/pull/5186
We're using "@uppy/svelte": "^4.0.2" and are encountering the following TypeScript error:
Svelte: Cannot find module '@uppy/svelte' or its corresponding type declarations
As a workaround, we have to include the following directive in our code:
// @ts-expect-error: The module '@uppy/svelte' has no type definitions available.
It would be great if official type definitions for @uppy/svelte could be provided so that we can avoid the need for this exception.
Issue reported here: #5475.
Closing this as we did actually add types to the package and it's published. But in the meantime a different build error slipped in.