fix: make sure classes in lib correctly implement Electron interfaces (#40291)

This commit is contained in:
Milan Burda 2023-10-25 14:02:15 -04:00 committed by GitHub
parent 514a9319b9
commit f66d4c7ee0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 21 additions and 17 deletions

View file

@ -2,7 +2,7 @@ import { app } from 'electron/main';
import { EventEmitter } from 'events';
import * as squirrelUpdate from '@electron/internal/browser/api/auto-updater/squirrel-update-win';
class AutoUpdater extends EventEmitter {
class AutoUpdater extends EventEmitter implements Electron.AutoUpdater {
updateAvailable: boolean = false;
updateURL: string | null = null;
@ -15,7 +15,7 @@ class AutoUpdater extends EventEmitter {
}
getFeedURL () {
return this.updateURL;
return this.updateURL ?? '';
}
setFeedURL (options: { url: string } | string) {

View file

@ -3,7 +3,7 @@ import * as deprecate from '@electron/internal/common/deprecate';
const binding = process._linkedBinding('electron_browser_crash_reporter');
class CrashReporter {
class CrashReporter implements Electron.CrashReporter {
start (options: Electron.CrashReporterStartOptions) {
const {
productName = app.name,

View file

@ -1,10 +1,12 @@
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
import { EventEmitter } from 'events';
const { createPair } = process._linkedBinding('electron_browser_message_port');
export default class MessageChannelMain {
export default class MessageChannelMain extends EventEmitter implements Electron.MessageChannelMain {
port1: MessagePortMain;
port2: MessagePortMain;
constructor () {
super();
const { port1, port2 } = createPair();
this.port1 = new MessagePortMain(port1);
this.port2 = new MessagePortMain(port2);

View file

@ -8,7 +8,7 @@ const {
isOnBatteryPower
} = process._linkedBinding('electron_browser_power_monitor');
class PowerMonitor extends EventEmitter {
class PowerMonitor extends EventEmitter implements Electron.PowerMonitor {
constructor () {
super();
// Don't start the event source until both a) the app is ready and b)

View file

@ -1,9 +1,11 @@
import { BrowserWindow, Menu, SharingItem, PopupOptions } from 'electron/main';
import { EventEmitter } from 'events';
class ShareMenu {
class ShareMenu extends EventEmitter implements Electron.ShareMenu {
private menu: Menu;
constructor (sharingItem: SharingItem) {
super();
this.menu = new (Menu as any)({ sharingItem });
}

View file

@ -4,7 +4,7 @@ import { Socket } from 'net';
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
const { _fork } = process._linkedBinding('electron_browser_utility_process');
class ForkUtilityProcess extends EventEmitter {
class ForkUtilityProcess extends EventEmitter implements Electron.UtilityProcess {
#handle: ElectronInternal.UtilityProcessWrapper | null;
#stdout: Duplex | null = null;
#stderr: Duplex | null = null;