Skip to content

Commit

Permalink
Correct DecoratedComponent type to be TargetClass
Browse files Browse the repository at this point in the history
  • Loading branch information
lukyth committed Oct 30, 2018
1 parent 33c6c50 commit b101a83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 1 addition & 3 deletions packages/react-dnd/src/DragSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ export default function DragSource<Props, CollectedProps = {}, DragObject = {}>(
registerHandler: registerSource,
createMonitor: createSourceMonitor,
createConnector: createSourceConnector,
DecoratedComponent: (DecoratedComponent as any) as React.ComponentType<
Props
>,
DecoratedComponent,
getType,
collect,
options,
Expand Down
4 changes: 1 addition & 3 deletions packages/react-dnd/src/DropTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ export default function DropTarget<Props, CollectedProps = {}>(
registerHandler: registerTarget,
createMonitor: createTargetMonitor,
createConnector: createTargetConnector,
DecoratedComponent: (DecoratedComponent as any) as React.ComponentType<
Props
>,
DecoratedComponent,
getType,
collect,
options,
Expand Down
12 changes: 8 additions & 4 deletions packages/react-dnd/src/decorateHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const invariant = require('invariant')
const hoistStatics = require('hoist-non-react-statics')
const shallowEqual = require('shallowequal')

export interface DecorateHandlerArgs<Props, ItemIdType> {
DecoratedComponent: React.ComponentType<Props>
export interface DecorateHandlerArgs<Props, TargetClass, ItemIdType> {
DecoratedComponent: TargetClass
createHandler: any
createMonitor: any
createConnector: any
Expand All @@ -25,7 +25,11 @@ export interface DecorateHandlerArgs<Props, ItemIdType> {
options: any
}

export default function decorateHandler<Props, TargetClass, ItemIdType>({
export default function decorateHandler<
Props,
TargetClass extends React.ComponentType<any>,
ItemIdType
>({
DecoratedComponent,
createHandler,
createMonitor,
Expand All @@ -35,7 +39,7 @@ export default function decorateHandler<Props, TargetClass, ItemIdType>({
getType,
collect,
options,
}: DecorateHandlerArgs<Props, ItemIdType>): TargetClass &
}: DecorateHandlerArgs<Props, TargetClass, ItemIdType>): TargetClass &
DndComponentClass<Props> {
const { arePropsEqual = shallowEqual } = options
const Decorated: any = DecoratedComponent
Expand Down

0 comments on commit b101a83

Please sign in to comment.