What does the error “JSX element type '…' does not have any construct or call signatures” mean?

后端 未结 13 2316
余生分开走
余生分开走 2020-11-28 02:05

I wrote some code:

function renderGreeting(Elem: React.Component) {
    return Hello, !;
}
         


        
13条回答
  •  误落风尘
    2020-11-28 02:47

    In my case I was missing new inside the type definition.

    some-js-component.d.ts file:

    import * as React from "react";
    
    export default class SomeJSXComponent extends React.Component {
        new (props: any, context?: any)
    }
    

    and inside the tsx file where I was trying to import the untyped component:

    import SomeJSXComponent from 'some-js-component'
    
    const NewComp = ({ asdf }: NewProps) => 
    

提交回复
热议问题