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

Typescript: Unable to use Sensors in Droppable #498

Open
Git-Hub-User-0 opened this issue Jul 15, 2021 · 1 comment
Open

Typescript: Unable to use Sensors in Droppable #498

Git-Hub-User-0 opened this issue Jul 15, 2021 · 1 comment

Comments

@Git-Hub-User-0
Copy link

Git-Hub-User-0 commented Jul 15, 2021

Hi
I am getting while adding Sensors to Droppable(using Typescript):

import { Droppable, Sensors, DragSensor } from "@shopify/draggable";
const droppable = new Droppable(document.querySelectorAll(".app"), {
      draggable: ".item",
      dropzone: ".dropzone",
      sensors: [Sensors.DragSensor] || [DragSensor]
    });

Error: 'Sensors' only refers to a type, but is being used as a value here

If i try to add DragSensor directly, then i getting following error:
Type 'typeof DragSensor' is missing the following properties from type 'Sensor': attach, detach, addContainer, removeContainer, trigger

"@shopify/draggable": "^1.0.0-beta.12"

Please help with this.
Thanks in advance.

@zjffun

@Git-Hub-User-0 Git-Hub-User-0 changed the title Unable to use Sensors in Droppable Typescript: Unable to use Sensors in Droppable Jul 15, 2021
@zjffun
Copy link
Contributor

zjffun commented Jul 15, 2021

Thank you for your bug report.

I can't find a temporary way to fix class type define. It seems that it can only be temporarily fixed by setting the any type now.

import { Droppable, DragSensor } from "@shopify/draggable";

const droppable = new Droppable(document.querySelectorAll(".app"), {
  draggable: ".item",
  dropzone: ".dropzone",
  sensors: [DragSensor as any],
});

I will create a PR to fix it.

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

2 participants