Webstorm 在将不存在的属性传递给组件时不显示打字稿错误

问题描述 投票:0回答:0

我有一个 Webstorm 项目可以正常工作,但另一个项目不能正常工作 - 自动完成正在工作,但如果我尝试创建一个具有不存在的 prop 的组件,Webstorm 不会告诉我有问题。我已经检查了两个项目的设置,以及 tsconfig.json,看不出区别在哪里。什么设置可能会导致一个项目中出现这种情况而不是另一个项目?

type Props = {
    text: string
}

const Test = ({text}: Props) => {
    return(
        <div>{text}</div>
    )
}

const Test2 = () => {
  return (
      <Test
          text={'test'}
          anything={'test'} <--- This should display an error
      />
  )
}

我的 tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}
reactjs typescript webstorm
© www.soinside.com 2019 - 2024. All rights reserved.