TypeScript - Property is missing in type DndComponent
See original GitHub issueHi,
Thanks for the react-dnd library, very nice work. I have the following two typing issues with the following sample code. I appreciate if someone could tell me what am i doing wrong ?
export interface TestProps {
}
@DropTarget<TestProps>("TEST", {
drop(props: TestProps) {
}
}, (connect, monitor) => {
return { dragTarget: connect.dropTarget() };
})
export class TestComponent extends React.Component<TestProps, undefined> {
constructor(props: TestProps) {
super(props);
}
someHelper() {
return (<h1>Test</h1>);
}
render() {
return (this.props as any).dragTarget(this.someHelper());
}
}
- Is there a better way of doing
return (this.props as any).dragTarget(this.someHelper());
- The following code produces the error below, any ideas?
TS1238: Unable to resolve signature of class decorator when called as an expression. Type 'DndComponentClass<TestProps>' is not assignable to type 'typeof TestComponent'. Type 'DndComponent<TestProps, any>' is not assignable to type 'TestComponent'. Property 'someHelper' is missing in type 'DndComponent<TestProps, any>'.
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Error "Property 'type' is missing in type 'typeof WithXXX'"
DragSource expects a React component as an input, but you're trying to pass your withTemplateObjectDraggable HOC in. Hence Typescript complains ...
Read more >React.js: Property is missing in type but required in type
The React.js error "Property is missing in type but required in type" occurs when we don't pass all of the required props to...
Read more >Useful Patterns by Use Case - React TypeScript Cheatsheets
Just as you can make generic functions and classes in TypeScript, you can also make ... {/* Error: Property 'toPrecision' does not exist...
Read more >Docs - React DnD
When you drag something across the screen, we don't say that a component, or a DOM node is being dragged. Instead, we say...
Read more >Property 'children' is missing in type '{}'
Hello, I got the same TypeScript error as this friend here: forge/ui version: 0.13.1 and 0.13.1-next.0 [tsl] ERROR in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having the same issue. Anything added inside the React Component class causes an error - even the render function. An empty class is the only thing that doesn’t produce an error. As far as I can tell it happens with DragSource, DropTarget, and DragDropContext decorators.
if you uninstall the typings for react-dnd, the error is gone and it works. However, of course, you loose intellisense, just a workaround