采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
老师,我这react-native的版本是0.62的,使用react-native-template-typescript初始化项目后,没有tsconfig.json,这是漏了哪部分吗,还是直接用你的tsconfig.json,复制到项目根目录就行
初始化项目命令
最后有报错,说是也可以运行
但是打开项目没有ts
{ "name": "ximalaya", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@react-native-community/masked-view": "^0.1.10", "@react-navigation/bottom-tabs": "^5.4.1", "@react-navigation/native": "^5.2.4", "@react-navigation/stack": "^5.3.0", "@types/react-redux": "^7.1.8", "dva-core-ts": "^2.0.7", "react": "16.11.0", "react-native": "0.62.2", "react-native-config": "^1.0.0", "react-native-gesture-handler": "^1.6.1", "react-native-reanimated": "^1.8.0", "react-native-safe-area-context": "^0.7.3", "react-native-screens": "^2.7.0", "react-redux": "^7.2.0" }, "devDependencies": { "@babel/core": "^7.6.2", "@babel/runtime": "^7.6.2", "@react-native-community/eslint-config": "^0.0.5", "@types/react": "^16.9.34", "@types/react-native": "^0.62.7", "babel-jest": "^24.9.0", "babel-plugin-module-resolver": "^4.0.0", "eslint": "^6.5.1", "jest": "^24.9.0", "metro-react-native-babel-preset": "^0.58.0", "react-test-renderer": "16.11.0", "typescript": "^3.8.3" }, "jest": { "preset": "react-native" } }
可以贴出你的package.json文件吗?你可能在初始化的时候没有正确的使用typescript的模版
我就是用初始化项目那段命令初始的项目,然后依赖里的typescript是手动添加的
添加了依赖就没什么问题,把tsconfig.json复制过去
是的,后面也正常学习,谢谢老师
登录后可查看更多问答,登录/注册
从入门到实战,掌握用TypeScript开发ReactNative应用
1.1k 38
896 21
1.4k 12
957 11
1.2k 11