SortableJS / react-sortablejs

React bindings for SortableJS
http://sortablejs.github.io/react-sortablejs/
MIT License
2.01k stars 208 forks source link

TS2304: Cannot find name 'Sortable'. #186

Open dgreuel opened 3 years ago

dgreuel commented 3 years ago

Getting these errors when trying to build my project

node_modules/react-sortablejs/dist/index.d.ts:27:40 - error TS2304: Cannot find name 'Sortable'.

27     setList: (newState: T[], sortable: Sortable | null, store: Store) => void;
                                          ~~~~~~~~

node_modules/react-sortablejs/dist/index.d.ts:61:104 - error TS2304: Cannot find name 'Sortable'.

61 export type ReactSortableOptions = Partial<Record<AllMethodsExceptMove, (evt: SortableEvent, sortable: Sortable | null, store: Store) => void>> & {
                                                                                                          ~~~~~~~~

node_modules/react-sortablejs/dist/index.d.ts:69:63 - error TS2304: Cannot find name 'Sortable'.

69     onMove?: (evt: MoveEvent, originalEvent: Event, sortable: Sortable | null, store: Store) => boolean | -1 | 1 | void;

yarn.lock has these versions:

"@types/sortablejs@^1.10.6":
  version "1.10.6"
react-sortablejs@^6.0.0:
  version "6.0.0"
sortablejs@^1.10.6:
  version "1.12.0"
waynevanson commented 3 years ago

Does setting skipLibCheck: false or other skip* settings fix this?

wdoug commented 3 years ago

Using skipLibCheck does allow it to run, but so does adding Sortable to the import in dist/index.d.ts, which is already importing other things from sortablejs.

- import { MoveEvent, Options, SortableEvent } from "sortablejs";
+ import Sortable, { MoveEvent, Options, SortableEvent } from "sortablejs";

This seems preferable. How does that file get built?

wdoug commented 3 years ago

At first glance, it looks like it should already be included here. ❓

dgreuel commented 3 years ago

That's what I found as well...not sure why that import doesn't end up in the compiled definitions file.

At first glance, it looks like it should already be included here. ❓

wdoug commented 3 years ago

I wonder if this is the same underlying issue from Parcel: https://github.com/parcel-bundler/parcel/issues/4250

What was the reason for switching to Parcel for building this library? At least the Parcel-2 beta doesn't quite seem ready

kamster94 commented 3 years ago

Is that issue going to be resolved? It prevents me from publishing app, and I don't want to use skips

huangchen1031 commented 2 years ago

Use parcel@2.0.1 to build can resolve this problem.