简体   繁体   English

electron-reload typescript 编译成错误的 object(为 electronReload['default'])

[英]electron-reload typescript compiled to a wrong object ( to be electronReload['default'])

I am trying to learn typescript with electron a bit, using a template "electron-quick-start-typescript" ( https://github.com/electron/electron-quick-start-typescript ).我正在尝试使用模板“electron-quick-start-typescript”( https://github.com/electron/electron-quick-start-typescript )学习 typescript 和 electron。 I want to add a hot reload function to the template so I could hot reload while editing the code.我想在模板中添加热重载 function,这样我就可以在编辑代码时热重载。 I am trying to add我正在尝试添加

import electronReload from "electron-reload";
electronReload(__dirname, {});

these two lines of code, but after the compilation it became这两行代码,编译之后就变成了

var electron_reload_1 = require("electron-reload");
(0, electron_reload_1["default"])(__dirname, {});

where electron_reload_1["default"] cannot be recognised.无法识别electron_reload_1["default"]的地方。 I can run the compiled js while I manually changed electron_reload_1["default"] to electron_reload_1 .当我手动将electron_reload_1["default"]更改为electron_reload_1时,我可以运行编译后的 js。

I guess the problem is because in electron-reload lib, it is not using export default module to export a function. Does anyone has experience on making typescript + electron hot reloadable?我猜问题是因为在 electron-reload lib 中,它没有使用export default module来导出 function。有没有人有制作 typescript + electron 热重载的经验? Thank you.谢谢你。

I just found that adding "esModuleInterop": true in tsconfig.json would solve this problem.我刚刚发现在 tsconfig.json 中添加"esModuleInterop": true可以解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM