Skip to content

Commit

Permalink
fix: Export types from main and renderer, fix main types (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
ffflorian authored Jun 2, 2021
1 parent 0340124 commit 1502a4c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 19 deletions.
76 changes: 58 additions & 18 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,60 @@
interface NodeRequireFunction {
(moduleName: 'electron'): typeof Electron;
}

interface NodeRequire extends NodeRequireFunction {
resolve: RequireResolve;
cache: NodeRequireCache;
/**
* @deprecated
*/
extensions: NodeExtensions;
main: NodeModule | undefined;
}

export declare var require: NodeRequire;
import * as Electron from 'electron';

// Taken from `RemoteMainInterface`
export {app, autoUpdater, BrowserView, BrowserWindow, ClientRequest, clipboard, CommandLine, contentTracing, Cookies, crashReporter, Debugger, desktopCapturer, dialog, Dock, DownloadItem, globalShortcut, inAppPurchase, IncomingMessage, ipcMain, Menu, MenuItem, MessageChannelMain, MessagePortMain, nativeImage, nativeTheme, net, netLog, Notification, powerMonitor, powerSaveBlocker, protocol, screen, ServiceWorkers, session, shell, systemPreferences, TouchBar, TouchBarButton, TouchBarColorPicker, TouchBarGroup, TouchBarLabel, TouchBarOtherItemsProxy, TouchBarPopover, TouchBarScrubber, TouchBarSegmentedControl, TouchBarSlider, TouchBarSpacer, Tray, webContents, WebRequest} from 'electron';
export * from './dist/src/main'
export * from './dist/src/renderer';
export var app: Electron.App;
export var autoUpdater: Electron.AutoUpdater;
export var BrowserView: typeof Electron.BrowserView;
export var BrowserWindow: typeof Electron.BrowserWindow;
export var ClientRequest: typeof Electron.ClientRequest;
export var clipboard: Electron.Clipboard;
export var CommandLine: typeof Electron.CommandLine;
export var contentTracing: Electron.ContentTracing;
export var Cookies: typeof Electron.Cookies;
export var crashReporter: Electron.CrashReporter;
export var Debugger: typeof Electron.Debugger;
export var desktopCapturer: Electron.DesktopCapturer;
export var dialog: Electron.Dialog;
export var Dock: typeof Electron.Dock;
export var DownloadItem: typeof Electron.DownloadItem;
export var globalShortcut: Electron.GlobalShortcut;
export var inAppPurchase: Electron.InAppPurchase;
export var IncomingMessage: typeof Electron.IncomingMessage;
export var ipcMain: Electron.IpcMain;
export var Menu: typeof Electron.Menu;
export var MenuItem: typeof Electron.MenuItem;
export var MessageChannelMain: typeof Electron.MessageChannelMain;
export var MessagePortMain: typeof Electron.MessagePortMain;
export var nativeImage: typeof Electron.NativeImage;
export var nativeTheme: Electron.NativeTheme;
export var net: Electron.Net;
export var netLog: Electron.NetLog;
export var Notification: typeof Electron.Notification;
export var powerMonitor: Electron.PowerMonitor;
export var powerSaveBlocker: Electron.PowerSaveBlocker;
export var protocol: Electron.Protocol;
export var screen: Electron.Screen;
export var ServiceWorkers: typeof Electron.ServiceWorkers;
export var session: typeof Electron.Session;
export var shell: Electron.Shell;
export var systemPreferences: Electron.SystemPreferences;
export var TouchBar: typeof Electron.TouchBar;
export var TouchBarButton: typeof Electron.TouchBarButton;
export var TouchBarColorPicker: typeof Electron.TouchBarColorPicker;
export var TouchBarGroup: typeof Electron.TouchBarGroup;
export var TouchBarLabel: typeof Electron.TouchBarLabel;
export var TouchBarOtherItemsProxy: typeof Electron.TouchBarOtherItemsProxy;
export var TouchBarPopover: typeof Electron.TouchBarPopover;
export var TouchBarScrubber: typeof Electron.TouchBarScrubber;
export var TouchBarSegmentedControl: typeof Electron.TouchBarSegmentedControl;
export var TouchBarSlider: typeof Electron.TouchBarSlider;
export var TouchBarSpacer: typeof Electron.TouchBarSpacer;
export var Tray: typeof Electron.Tray;
export var webContents: typeof Electron.WebContents;
export var WebRequest: typeof Electron.WebRequest;

// Taken from `Remote`
export function getCurrentWebContents(): Electron.WebContents;
export function getCurrentWindow(): Electron.BrowserWindow;
export function getGlobal(name: string): any;
export var process: NodeJS.Process;
export var require: NodeJS.Require;
1 change: 1 addition & 0 deletions main/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../dist/src/main';
1 change: 1 addition & 0 deletions renderer/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../dist/src/renderer';
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"strict": true,
"esModuleInterop": true
},
"exclude": ["index.d.ts"]
"exclude": ["index.d.ts", "main", "renderer"]
}

1 comment on commit 1502a4c

@crutchcorn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When can we expect this published? This is a blocker for some migration work I'm doing

Please sign in to comment.