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

TSX support for the example code #60

Closed
ken-okabe opened this issue Sep 22, 2022 · 3 comments
Closed

TSX support for the example code #60

ken-okabe opened this issue Sep 22, 2022 · 3 comments

Comments

@ken-okabe
Copy link

Thanks for the great component I've been lookin for.

Sortable list (vertical) in
https://solid-dnd.com/#examples
https://gist.github.com/stken2050/84de233a3f759c679dc0a6cbcfff6c50
as Sortable.jsx wokrs fine, but basically my projects are based on TS, TSX, so tried as Sortable.tsx, then unsurprisingly had errors.

image

(property) use:sortable: true
Type '{ children: any; "use:sortable": true; class: string; classList: { "opacity-25": boolean; "transition-transform": boolean; }; }' is not assignable to type 'HTMLAttributes<HTMLDivElement>'.
  Property 'use:sortable' does not exist on type 'HTMLAttributes<HTMLDivElement>'.ts(2322)

image

Type 'Element' is not assignable to type '(Element | ((activeDraggable: Draggable) => Element)) & Element'.
  Type 'number' is not assignable to type '(Element | ((activeDraggable: Draggable) => Element)) & Element'.ts(2322)
drag-overlay.d.ts(4, 5): The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & DragOverlayProps & { children?: Element; }'

What is the proper way to avoid this error?

TSX support would be very nice. Thanks!

@martinpengellyphillips
Copy link
Contributor

  1. You need to declare the custom Directives you are using. E.g you can add a types.d.tsx with the following:
import "solid-js";

declare module "solid-js" {
  namespace JSX {
    interface Directives {
      draggable: boolean;
      droppable: boolean;
      sortable: boolean;
    }
  }
}
  1. This was a bug in the typings and should now be fixed in 0.7.2

@thdxr
Copy link

thdxr commented Oct 8, 2022

I'm also seeing an issue where the transforms aren't applied with the code in the gist. Am I missing something?

@martinpengellyphillips
Copy link
Contributor

@thdxr that gist is running correctly on the solid-dnd.com site so hard to say without more info from you. Please open a new issue though as I'm closing this one.

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

3 participants