Move electron type augmentation to separate dts file

This commit is contained in:
Labhansh Agrawal 2020-09-15 19:47:52 +05:30 committed by Benjamin Staneck
parent 3dc172daf7
commit 507ff2ee9e
2 changed files with 22 additions and 22 deletions

22
app/extend-electron.d.ts vendored Normal file
View file

@ -0,0 +1,22 @@
import type {Server} from './rpc';
declare module 'electron' {
interface App {
config: typeof import('./config');
plugins: typeof import('./plugins');
getWindows: () => Set<BrowserWindow>;
getLastFocusedWindow: () => BrowserWindow | null;
windowCallback: (win: BrowserWindow) => void;
createWindow: (fn?: (win: BrowserWindow) => void, options?: Record<string, any>) => BrowserWindow;
setVersion: (version: string) => void;
}
// type Server = import('./rpc').Server;
interface BrowserWindow {
uid: string;
sessions: Map<any, any>;
focusTime: number;
clean: () => void;
rpc: Server;
}
}

View file

@ -47,28 +47,6 @@ import {gitDescribe} from 'git-describe';
import isDev from 'electron-is-dev';
import * as config from './config';
// Hack - this declararion doesn't work when put into ./ext-modules.d.ts for some reason so it's in this file for the time being
declare module 'electron' {
interface App {
config: typeof import('./config');
plugins: typeof import('./plugins');
getWindows: () => Set<BrowserWindow>;
getLastFocusedWindow: () => BrowserWindow | null;
windowCallback: (win: BrowserWindow) => void;
createWindow: (fn?: (win: BrowserWindow) => void, options?: Record<string, any>) => BrowserWindow;
setVersion: (version: string) => void;
}
type Server = import('./rpc').Server;
interface BrowserWindow {
uid: string;
sessions: Map<any, any>;
focusTime: number;
clean: () => void;
rpc: Server;
}
}
// set up config
config.setup();