react-sortablejs icon indicating copy to clipboard operation
react-sortablejs copied to clipboard

TS2304: Cannot find name 'Sortable'.

Open dgreuel opened this issue 3 years ago • 7 comments

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"

dgreuel avatar Sep 28 '20 22:09 dgreuel

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

waynevanson avatar Sep 29 '20 01:09 waynevanson

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 avatar Oct 07 '20 17:10 wdoug

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

wdoug avatar Oct 07 '20 17:10 wdoug

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. ❓

dgreuel avatar Oct 07 '20 17:10 dgreuel

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

wdoug avatar Oct 07 '20 18:10 wdoug

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

kamster94 avatar Nov 19 '20 12:11 kamster94

Use [email protected] to build can resolve this problem.

huangchen1031 avatar Nov 29 '21 12:11 huangchen1031