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