svelte-cloudinary icon indicating copy to clipboard operation
svelte-cloudinary copied to clipboard

[Bug] Property 'default 'does not exist on type '{}' when using CldUploadWidget let:open

Open Synexcu opened this issue 9 months ago • 1 comments

Bug Report

When following the video tutorial at Svelte Cloudinary Upload Widget site, an error occurred in Visual Studio Code with the following:

Property 'default' does not exist on type '{}'.ts(2339)
const open: any

Though the website actually works fine and the code to upload image to cloudinary works perfectly, the code however produces a warning that is shown by the Visual Studio Code.

Is this a regression?

I am not too sure.

Steps To Reproduce the error

Here is the code snippet of my current code:

<script lang="ts">
    import type { PageData } from './$types';
    import { Button } from '$lib/components/ui/button';
    import { Input } from '$lib/components/ui/input'
    import * as Form from '$lib/components/ui/form';
    import SuperDebug, { superForm } from 'sveltekit-superforms';
    import { toast } from 'svelte-sonner';
    import { goto } from '$app/navigation';
    import { formSchema } from './schema';
    import { zodClient } from 'sveltekit-superforms/adapters';
    import FormField from '$lib/components/ui/form/form-field.svelte';
    import { FormInput } from 'lucide-svelte';
    import { CldUploadButton, CldUploadWidget, CldImage, getCldImageUrl } from 'svelte-cloudinary';

const onUpload = (result:any, widget:any) => {
        // onChange(result.info.secure_url);
        if (result.event == "success") {
            info = result.info;
            secure_url = result.info.secure_url
            toast.success('Upload image to CLOUD successful!');
            $formData.link = result.info.secure_url
        } else if (result.event === "error") {
            error = result.error.status
        }
        widget.close()
    };

</script>

. . . .

        <CldUploadWidget uploadPreset={uploadPresetKey} {onUpload} let:open>
            <Button on:click={open}>    
                Upload Test
            </Button>
        </CldUploadWidget>

Expected behaviour

I expected that because of the warning from the Visual Studio Code, the bug makes the actual button not usable, but instead it actually works fine as intended like in the video without any problems. The Visual Studio Code was just showing an error, but the code itself works? I have no idea how that works.

Screenshot or Video Recording

image

Your environment

  • OS: Windows 11 Version 23H2 (OS Build 22631.3447) x64
  • Node version: v.20.12.1
  • bun version: v1.1.4
  • Browser name and version: Microsoft Edge 124.0.2478.67 (Official build) (64-bit)

Synexcu avatar Apr 30 '24 05:04 Synexcu