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

Consider adding TypeScript declarations for uppy Svelte package #3123

Closed
apirogov opened this issue Aug 20, 2021 · 11 comments
Closed

Consider adding TypeScript declarations for uppy Svelte package #3123

apirogov opened this issue Aug 20, 2021 · 11 comments
Labels
Svelte Types Issues relating to the Typescript definition files

Comments

@apirogov
Copy link

apirogov commented Aug 20, 2021

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.

@Murderlon Murderlon added Svelte Types Issues relating to the Typescript definition files and removed Feature Triage labels Dec 2, 2021
@stale
Copy link

stale bot commented Dec 3, 2022

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.

@stale stale bot added the Stale Old issues that haven't had activity recently label Dec 3, 2022
@frederikhors
Copy link
Contributor

Nope

@stale stale bot removed the Stale Old issues that haven't had activity recently label Dec 3, 2022
@Romeo-V1
Copy link

Romeo-V1 commented Jun 9, 2023

This would be very nice to have, is there currently a temp work around for this?

@Flajt
Copy link

Flajt commented Jun 12, 2023

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.

@ApioSoftwareSolutions
Copy link

ApioSoftwareSolutions commented Apr 22, 2024

what a horrible workaround, the same issue of types happens with react

@Murderlon
Copy link
Member

Note that we're done with the complete transition of the codebase to TS. It will be released soon under 4.0.0

@Murderlon
Copy link
Member

Or use it today in the beta: https://www.npmjs.com/package/@uppy/svelte/v/4.0.0-beta.1

@cellulosa
Copy link

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} />

@Murderlon
Copy link
Member

@cellulosa fixed in #5186

@abudin
Copy link

abudin commented Oct 3, 2024

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.

@Murderlon
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Svelte Types Issues relating to the Typescript definition files
Projects
None yet
Development

No branches or pull requests

8 participants