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