question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript - Property is missing in type DndComponent

See original GitHub issue

Hi,

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());
    }
}

  1. Is there a better way of doing return (this.props as any).dragTarget(this.someHelper());
  2. 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
lukescottcommented, Jul 20, 2017

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.

2reactions
LeopoldLerchcommented, Jun 7, 2017

if you uninstall the typings for react-dnd, the error is gone and it works. However, of course, you loose intellisense, just a workaround

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found