Skip to content

Commit

Permalink
fix(multi-backend): use react-dnd-touch-backend's own Typescript de…
Browse files Browse the repository at this point in the history
…finitions

You may find on recent versions of the backend you need to write `TouchBackend({ ...opts }) as BackendFactory` to avoid the under-specification that TouchBackend(arg) could produce an actual backend if arg is a DragDropManager, so the output type is `TouchBackend | BackendFactory`.

Not a breaking change because those typings were aspirational only, meant as a stopgap re-export so users wouldn't have to wrangle with ambient definitions, not part of multi-backend's public API. The same goes for `dnd-multi-backend`.
  • Loading branch information
cormacrelf committed Jun 16, 2019
1 parent 98e4561 commit 5de8ec0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
2 changes: 1 addition & 1 deletion packages/examples/src/app/customMultiBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const backendTransitions: BackendTransition[] = [
enableMouseEvents: false,
ignoreContextMenu: true,
delayTouchStart: 200, // milliseconds
}),
}) as BackendFactory,
transition: TouchTransition,
preview: true,
}
Expand Down
19 changes: 0 additions & 19 deletions packages/multi-backend/src/ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,3 @@ declare module "dnd-multi-backend" {
export const MouseTransition: Transition;
}

declare module "react-dnd-touch-backend" {
import { Backend, BackendFactory } from "dnd-core";
export interface AngleRange {
start: number, // degrees, moving clockwise with 0/360 = pointing left
end: number, // degrees, moving clockwise with 0/360 = pointing left
}
export interface TouchBackendOptions {
enableMouseEvents?: boolean;
enableTouchEvents?: boolean,
enableKeyboardEvents?: boolean,
ignoreContextMenu?: boolean,
delayTouchStart?: number, // ms
delayMouseStart?: number, // ms
touchSlop?: number, // px
scrollAngleRanges?: AngleRange[] | undefined,
}
const TouchBackend: (options: TouchBackendOptions) => BackendFactory;
export default TouchBackend;
}

0 comments on commit 5de8ec0

Please sign in to comment.