[英]How to get node types in Electron with react typescript?
in React App.tsx
在 React
App.tsx
中
const fs = window.require('fs')
fs.readFile(....)
If I want to use node module inside electron React project, I shoud require 'fs' from window, but this would loose node module types and intelliSense如果我想在 electron React 项目中使用节点模块,我应该要求 window 中的“fs”,但这会丢失节点模块类型和智能感知
You can use TypeScript import() types .您可以使用 TypeScript import() 类型。
const fs: typeof import("fs") = window.require('fs');
fs.readFile(...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.