When I write below code in Electron in TypeScript,
const { app, BrowserWindow } = require("electron");
let mainWindow: Electron.BrowserWindow;
I got this error: Cannot find namespace 'Electron'.
.
I seems there is not namespace defined for the type Electron
. I wonder where I can load this type definition. I have added these dependencies on my project:
"electron": "^5.0.2",
No need to prefix your usage of BrowserWindow
. You've already got the type imported, just use it directly.
import { BrowserWindow } from "electron";
let mainWindow: BrowserWindow;
Additionally, you don't need a separate @types/electron
package for electron. The electron
package is already typed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.