我尝试将JSX Fragment语法与Typescript一起使用但是我有以下错误:
元素类型无效:期望一个字符串(用于内置组件)或一个类/函数(用于复合组件)但得到:符号
我正在使用:
即使我使用反应代码示例,也会失败:
public render() {
return (
<>
Some text.
<h2>A heading</h2>
More text.
<h2>Another heading</h2>
Even more text.
</>
);
}
tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"module": "es2015",
"moduleResolution": "node",
"target": "es5",
"jsx": "react",
"experimentalDecorators": true,
"sourceMap": true,
"skipDefaultLibCheck": true,
"strict": true,
"lib": ["es6", "dom"],
"types": ["webpack-env"]
},
"exclude": [
"bin",
"node_modules",
"app/__tests__"
]
}