I'm trying to get electron (0.37) and typescript (1.8), with Typings, working properly. I'm having trouble with the import of BrowserWindow. In older examples it seems to be a seperate require('browser-window')
, but in the current version its electron.BrowserWindow
.
following an example I found my TypeScript is:
import electron = require('electron');
const BrowserWindow = electron.BrowserWindow;
...
var mainWindow:BrowserWindow = new BrowserWindow({width: main_width, height: main_height});
Unfortunately WebStorm and its TypeScript compiler is complaining: "TS2304: Cannot find name BrowserWindow"; specifically at the variable declaration. if I remove the type declaration from the variable, it works.
var mainWindow = new BrowserWindow({width: main_width, height: main_height});
...but this seems to defeat the purpose of typescript though?
I've tried a few different ways around this, but cannot get it working properly. For instance, if I do: import BrowserWindow = Electron.BrowserWindow
the compiler is happy, but the javascript fails because Electron
(a typescript namespace) isn't defined.
Admittedly I'm new to typescript.
var mainWindow:BrowserWindow
You probably want :
var mainWindow:Electron.BrowserWindow
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With