在 expo & react native typescript 中,VS code IntelliSense 建议“react-native/types”,而不是“react-native”

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

我的 React Native TypeScript IntelliSense 是 suggestiong

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
作为开发依赖。这是我的
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"
  },
typescript react-native visual-studio-code expo intellisense
1个回答
0
投票

我将此配置用于我的所有项目。试试这个

{
  "extends": "expo/tsconfig.base",
  "compilerOptions": {
    "strict": true
  },
  "exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"],
  "jsx": "react-jsx",
  "baseUrl": "."
}
© www.soinside.com 2019 - 2024. All rights reserved.