electron+react项目改为typescript


1.添加typescript依赖

yarn add typescript

 

2.修改tsconfig.json

 "isolatedModules": true =>  "isolatedModules": false

 

3.js文件全部改为ts或tsx扩展名

 

4.修改package.json入口

 "main": "main.js" =>  "main": "main.ts"

 

5.修改引用方法

默认的electronmain中const xxx = require(xxxx),改为

improt {app, BrowserWindow} from 'electron'

 

6.Cannot find type definition file or 'react' TS2688

yarn add @types/react


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM