我的 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"
},
我将此配置用于我的所有项目。试试这个
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true
},
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"],
"jsx": "react-jsx",
"baseUrl": "."
}