I am following the example here and have this TypeScript code:
const { app, BrowserWindow, ipcMain } = require('electron');
let win;
function createWindow () {
// Create the browser window.
win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
// and load the index.html of the app.
win.loadFile('bin/js-debug/index.html')
// Open the DevTools.
//win.webContents.openDevTools()
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null
})
}
I changed the extension from .js to .ts and it started to show errors.
I get this warning:
Variable 'win' implicitly has type 'any' in some locations where its type cannot be determined.ts(7034)
So I tried to add the type like so:
let win:BrowserWindow;
and I get this message:
'BrowserWindow' refers to a value, but is being used as a type here.
NOTE:
If I set the type to any the error goes away.
let win:any;
const { app, BrowserWindow, ipcMain } = require('electron');
– 1.21 gigawatts