Search code examples
visual-studio-2013typescripttypescript1.6

TypeScript 1.6 error: JSX element type XXX does not have any construct or call signature


var CommentList = React.createClass({
          render: function () {
        return (
            <div className="commentList">
                Hello, world!I am a CommentList.
                </div>
        );
          }
});

var CommentBox = React.createClass({
          render: function () {
        return (
            <div className="commentBox">
                <h1>Comments</h1>
                <CommentList /> //ERROR
                </div>
        );
    }
});

React.render(
          React.createElement(CommentBox, null),
          document.getElementById('content')
);

With this code, I get the following error message: JSX element type 'CommentList' does not have any construct or call signatures.

The same code works with plain HTML/JS (following this tutorial: https://facebook.github.io/react/docs/tutorial.html)

I have no clue why TypeScript doesn't like it. Using Visual Studio 2013 with TS 1.6 (http://blogs.msdn.com/b/typescript/archive/2015/09/16/announcing-typescript-1-6.aspx)


Solution

  • It works fine without error (screen shot from atom-typescript) :

    enter image description here

    Suggestions:

    • Make sure visual studio is truly using typescript 1.6
    • Make sure you have react.d.ts included and try not to use the global version
    • Make sure you have the React variable available (e.g. import React = require('react');).