简体   繁体   中英

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

I wanted to use JS type checking capability inside VScode. Everything works like charm but React.Fragment is linted with error:

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.

My jsconfig.json is:

{
    "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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM