Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2013 TypeScript 1.6错误:JSX元素类型XXX没有任何构造或调用签名 var CommentList=React.createClass({ 渲染:函数(){ 返回( 你好,世界!我是一个评论列表。 ); } }); var CommentBox=React.createClass({ 渲染:函数(){ 返回( 评论 //错误 ); } }); 反应( React.createElement(CommentBox,null), document.getElementById('content') );_Visual Studio 2013_Typescript_Typescript1.6 - Fatal编程技术网

Visual studio 2013 TypeScript 1.6错误:JSX元素类型XXX没有任何构造或调用签名 var CommentList=React.createClass({ 渲染:函数(){ 返回( 你好,世界!我是一个评论列表。 ); } }); var CommentBox=React.createClass({ 渲染:函数(){ 返回( 评论 //错误 ); } }); 反应( React.createElement(CommentBox,null), document.getElementById('content') );

Visual studio 2013 TypeScript 1.6错误:JSX元素类型XXX没有任何构造或调用签名 var CommentList=React.createClass({ 渲染:函数(){ 返回( 你好,世界!我是一个评论列表。 ); } }); var CommentBox=React.createClass({ 渲染:函数(){ 返回( 评论 //错误 ); } }); 反应( React.createElement(CommentBox,null), document.getElementById('content') );,visual-studio-2013,typescript,typescript1.6,Visual Studio 2013,Typescript,Typescript1.6,使用此代码,我得到以下错误消息: JSX元素类型“CommentList”没有任何构造或调用签名。 同样的代码适用于纯HTML/JS(遵循本教程:) 我不知道为什么TypeScript不喜欢它。 使用Visual Studio 2013和TS 1.6()可以正常工作,没有错误(atom typescript的屏幕截图): 建议: 确保VisualStudio真正使用的是typescript 1.6 确保包含react.d.ts,并尽量不要使用全局版本 确保React变量可用(例如import

使用此代码,我得到以下错误消息: JSX元素类型“CommentList”没有任何构造或调用签名。

同样的代码适用于纯HTML/JS(遵循本教程:)

我不知道为什么TypeScript不喜欢它。
使用Visual Studio 2013和TS 1.6()

可以正常工作,没有错误(atom typescript的屏幕截图):

建议:

  • 确保VisualStudio真正使用的是typescript 1.6
  • 确保包含
    react.d.ts
    ,并尽量不要使用全局版本
  • 确保
    React
    变量可用(例如
    import React=require('React');

奇怪。在使用1.6.2从命令行编译时,对我来说效果很好。Typescript安装非常糟糕。我的环境路径中有Typescript/Typescript/1.2/Typescript/1.3/Typescript/1.4。当你认为你在引用1.6时,你可能没有引用。我发现了。。。我通过NuGet“react.TypeScript.DefinitelyTyped(V 0.1.12)”加载了react.d.ts文件。我用以下版本对其进行了更新:
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')
);