lxsmnsyc / solid-tippy

SolidJS bindings for Tippy.js
MIT License
35 stars 0 forks source link

 Property 'use:tippy' does not exist on type HTMLAttributes #1

Closed b-des closed 2 years ago

b-des commented 2 years ago

Hello @LXSMNSYC. I want to use your bindings but I faced with TS compilation error:   Property 'use:tippy' does not exist on type 'HTMLAttributes<HTMLDivElement>'.

Also I tried to use it as a hook, but it simply doesn't work - nothing happens.

Do you have any idea how to fix it?

b-des commented 2 years ago

Adding //@ts-ignore in JSX causes another error: tippy is not defined. My code: image

lxsmnsyc commented 2 years ago

Hi, thanks for reporting this issue. I forgot to mention on how directives are to be set up. You can follow this: https://www.solidjs.com/docs/latest/api#use%3A___

Then setup something like this:

import { TippyOptions } from 'solid-tippy';

declare module "solid-js" {
  namespace JSX {
    interface Directives {
      tippy: TippyOptions;
    }
  }
}

Another thing to note is that TypeScript doesn't understand directives, so it may remove the imports because it thinks that it is unused. However, you can do

import { tippy } from 'solid-tippy';
tippy; // emulate "usage"
b-des commented 2 years ago

Thank you for the answer. I've already managed. It's really tricky that TS removes imports which is used as a directives, it was bypassed by re-assigning the import to another constant