Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSX element type 'XXX' does not have any construct or call signatures

Tags:

typescript

jsx

I want to use material-ui in typescript.

/// <reference path="../../../typings/react/react.d.ts"/>
import React = __React;
import * as FlatButton from "material-ui/lib/flat-button";

interface ATCProps{
    clickHandler:__React.MouseEventHandler;
}

export default class AddToCartBtn extends React.Component<ATCProps,any>{
    render(){
        return (
            <FlatButton></FlatButton>  // -> error
        )
    }
}

flat-button.d.ts

declare module "material-ui/lib/flat-button" {
    import ReactElement = __React.ReactElement;
    import Component = __React.Component;
    interface FlatButton extends __React.Component<any,any>{
    }
    export default FlatButton;
}

Error:(15, 14) TS2604: JSX element type 'FlatButton' does not have any construct or call signatures.

like image 269
Zhaowei Avatar asked Oct 18 '22 21:10

Zhaowei


1 Answers

You need to replace interface FlatButton with class FlatButton. The module definition you've exported doesn't have any value associated with it.

like image 182
Ryan Cavanaugh Avatar answered Oct 27 '22 09:10

Ryan Cavanaugh