0

I am trying to find the correct way to close an Electron app. I make use of React and TypeScript within the app. I found this post and found a way that works:

const remote = require('electron').remote;
let w = remote.getCurrentWindow();
w.close();

But, TSLint tells me now that the require() style import is forbidden. Is there a cleaner way to close the Electron app?

Socrates
  • 8,724
  • 25
  • 66
  • 113

1 Answers1

2

A better way to this in TypeScript is to avoid require(). So, instead of requiring Electron the way you do, better importing remote within the import section and then accessing the remote variable. Now TSLint should be happy again.

import { remote } from 'electron';

...

private closeWindow() {
    remote.getCurrentWindow().close();
}
Neptunium
  • 36
  • 1