我已经升级到 Electron 14,重构了我的项目以适应“已删除:远程模块”重大更改,但由于以下 TypeScript 错误,我无法编译它:
Type '{ plugins: true; nodeIntegration: true; contextIsolation: false; enableRemoteModule: true; backgroundThrottling: false; webSecurity: false; }' is not assignable to type 'WebPreferences'.
Object literal may only specify known properties, and 'enableRemoteModule' does not exist in type 'WebPreferences'.ts(2322)
electron.d.ts(12612, 5): The expected type comes from property 'webPreferences' which is declared here on type 'BrowserWindowConstructorOptions'
Run Code Online (Sandbox Code Playgroud)
受影响的代码:
const window = new electron.BrowserWindow({
// ...
webPreferences: {
plugins: true,
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
backgroundThrottling: false,
webSecurity: …Run Code Online (Sandbox Code Playgroud)