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

on:clickoutside gives TS error #67

Open
1r00t opened this issue Mar 23, 2023 · 7 comments
Open

on:clickoutside gives TS error #67

1r00t opened this issue Mar 23, 2023 · 7 comments

Comments

@1r00t
Copy link

1r00t commented Mar 23, 2023

When I use the clickOutsideAction, typescript complains but it is working like it should.

grafik

Argument of type '{ class: string; "on:clickoutside": () => boolean; }' is not assignable to parameter of type 'Omit<Omit<HTMLAttributes<HTMLDivElement>, "data-sveltekit-keepfocus" | "data-sveltekit-noscroll" | "data-sveltekit-preload-code" | "data-sveltekit-preload-data" | ... 49 more ... | "aria-valuetext"> & EventsWithColon<...>, never> & HTMLAttributes<...>'.
  Object literal may only specify known properties, and '"on:clickoutside"' does not exist in type 'Omit<Omit<HTMLAttributes<HTMLDivElement>, "data-sveltekit-keepfocus" | "data-sveltekit-noscroll" | "data-sveltekit-preload-code" | "data-sveltekit-preload-data" | ... 49 more ... | "aria-valuetext"> & EventsWithColon<...>, never> & HTMLAttributes<...>'.ts(2345)
@1r00t
Copy link
Author

1r00t commented Mar 23, 2023

I found a solution, I needed to add this to app.d.ts in my SvelteKit project:

declare global {
    ...

    namespace svelteHTML {
        interface HTMLAttributes<T> {
            "on:clickoutside"?: (e: CustomEvent<T>) => void;
        }
    }
}

see here:
https://github.com/sveltejs/language-tools/blob/master/docs/preprocessors/typescript.md#im-getting-deprecation-warnings-for-sveltejsx--i-want-to-migrate-to-the-new-typings

@ankurrsinghal
Copy link
Owner

Ohh no, thanks for submitting this issue, will fix this, also I had a small improvement with the clickOutsideAction, as you know sometimes we need to pass a trigger element as well which is outside the container we want to close but we don't want to perform clickOutsideAction when clicked on trigger, because trigger already manages the visibility.

@ankurrsinghal
Copy link
Owner

We will push that update in another release!

@theetherGit
Copy link

@ankurrsinghal done with this?

@levinhtin
Copy link

The same error with longpress

Argument of type '{ type: "button"; "on:longpress": () => void; }' is not assignable to parameter of type 'Omit<Omit<HTMLButtonAttributes, "data-sveltekit-keepfocus" | "data-sveltekit-noscroll" | "data-sveltekit-preload-code" | "data-sveltekit-preload-data" | ... 49 more ... | "aria-valuetext"> & EventsWithColon<...>, never> & HTMLAttributes<...>'. Object literal may only specify known properties, and '"on:longpress"' does not exist in type 'Omit<Omit<HTMLButtonAttributes, "data-sveltekit-keepfocus" | "data-sveltekit-noscroll" | "data-sveltekit-preload-code" | "data-sveltekit-preload-data" | ... 49 more ... | "aria-valuetext"> & EventsWithColon<...>, never> & HTMLAttributes<...>'

@paolodina
Copy link

on:hover as well

@vlrevolution
Copy link

Still not fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants