From 507ff2ee9ed8f9d37fb2c0b2fe616c495e25d9e4 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Tue, 15 Sep 2020 19:47:52 +0530 Subject: [PATCH] Move electron type augmentation to separate dts file --- app/extend-electron.d.ts | 22 ++++++++++++++++++++++ app/index.ts | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 app/extend-electron.d.ts diff --git a/app/extend-electron.d.ts b/app/extend-electron.d.ts new file mode 100644 index 00000000..081da5e6 --- /dev/null +++ b/app/extend-electron.d.ts @@ -0,0 +1,22 @@ +import type {Server} from './rpc'; + +declare module 'electron' { + interface App { + config: typeof import('./config'); + plugins: typeof import('./plugins'); + getWindows: () => Set; + getLastFocusedWindow: () => BrowserWindow | null; + windowCallback: (win: BrowserWindow) => void; + createWindow: (fn?: (win: BrowserWindow) => void, options?: Record) => BrowserWindow; + setVersion: (version: string) => void; + } + + // type Server = import('./rpc').Server; + interface BrowserWindow { + uid: string; + sessions: Map; + focusTime: number; + clean: () => void; + rpc: Server; + } +} diff --git a/app/index.ts b/app/index.ts index 81a91c02..c629689a 100644 --- a/app/index.ts +++ b/app/index.ts @@ -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; - getLastFocusedWindow: () => BrowserWindow | null; - windowCallback: (win: BrowserWindow) => void; - createWindow: (fn?: (win: BrowserWindow) => void, options?: Record) => BrowserWindow; - setVersion: (version: string) => void; - } - - type Server = import('./rpc').Server; - interface BrowserWindow { - uid: string; - sessions: Map; - focusTime: number; - clean: () => void; - rpc: Server; - } -} - // set up config config.setup();