在expo & react native typescript中,VS代码IntelliSense建议使用'react-native/types',而不是'react-native'

disbfnqx  于 2023-04-12  发布在  React
关注(0)|答案(1)|浏览(207)

我的react native typescript IntelliSense建议使用react-native/types而不是react-native。如何解决?
我用npx create-expo-app MyApp --template Typescript安装了我的项目。
这是我的tsconfig.json

{
  "extends": "expo/tsconfig.base",
  "compilerOptions": {
    "strict": true,
    "jsx": "react"
  },
  "exclude": ["node_modules"]
}

我已经安装了@types/react-native作为dev-dependency。这是我的package.json

"dependencies": {
    "expo": "~48.0.10",
    "expo-status-bar": "~1.4.4",
    "react": "18.2.0",
    "react-native": "0.71.6"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/react": "~18.0.14",
    "@types/react-native": "^0.71.5",
    "typescript": "^4.9.4"
  },
rekjcdws

rekjcdws1#

我在所有的项目中都使用这个配置。

{
  "extends": "expo/tsconfig.base",
  "compilerOptions": {
    "strict": true
  },
  "exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"],
  "jsx": "react-jsx",
  "baseUrl": "."
}

相关问题