简体   繁体   English

<React.Fragment>在启用了checkJs的VScode中使用ts(2605)

[英]<React.Fragment> with ts(2605) in VScode with checkJs enabled

I wanted to use JS type checking capability inside VScode. 我想在VScode中使用JS类型检查功能。 Everything works like charm but React.Fragment is linted with error: 一切都像魅力一样工作,但是React.Fragment出错了:

JSX element type 'ReactElement<any>' is not a constructor function for JSX elements.
Type 'ReactElement<any>' is missing the following properties from type 'Element': nodeName, attributes, childrents(2605)

And this is not all, even imported components from material-ui show simillar ts(2605) error. 这还不是全部,甚至从material-ui导入的组件都显示simillar ts(2605)错误。

My jsconfig.json is: 我的jsconfig.json是:

{
    "compilerOptions": {
        "module": "commonjs",
        "checkJs": true,
        "target": "esnext",
        "jsx": "react",
        "allowSyntheticDefaultImports": true
    },
    "include": [
        "./**/*"
    ]
}

Can someone help me please to find out what am I doing wrong? 有人可以帮我找出我做错了什么吗?

Thanks. 谢谢。

这是有关@ types / react的问题,降级为“ @ types / react”:“ 16.7.13”。

yarn add @types/react@16.7.13

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React:在TS组件中使用ES6组件:TS2605:JSX元素类型&#39;xxx&#39;不是JSX元素的构造函数 - React: Using ES6 component in TS component: TS2605: JSX element type 'xxx' is not a constructor function for JSX elements VS Code 不理解 Tsx 中的简写 React.Fragment 标签 - VS Code Doesn't Understand Shorthand React.Fragment Tags In Tsx 未捕获的错误:[PrivateRoute] 不是<route>零件。 的所有子组件<routes>必须是<route>或者<react.fragment></react.fragment></route></routes></route> - Uncaught Error: [PrivateRoute] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment> VSCode React TS Intellisense 方式太慢 - VSCode React TS Intellisense way too slow 可选用 jsdoc、typescript checkjs (javascript) 反应 useState 类型 - optional react useState types with jsdoc, typescript checkjs (javascript) React.forwardRef 功能组件的 VSCode TS 错误 - VSCode TS error with React.forwardRef functional component “xxx”类型缺少“ElementClass”类型的以下属性:context、setState、forceUpdate、props 和另外 2 个。 TS2605 - Type 'xxx' is missing the following properties from type 'ElementClass': context, setState, forceUpdate, props, and 2 more. TS2605 VSCode 工作,但 TS 编译器抛出错误:VSCode 和 TS 编译器不同步 - VSCode works but TS compiler throws error: VSCode and TS compiler are not in sync React/Typescript - 语义错误 TS2304:找不到名称“片段” - React/Typescript - semantic error TS2304: Cannot find name 'Fragment' 类型检查无法与.ts文件上的VsCode一起使用 - Typechecking not working with VsCode on .ts files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM