diff --git a/filenames.auto.gni b/filenames.auto.gni index 1469d666c0..1b58bc2260 100644 --- a/filenames.auto.gni +++ b/filenames.auto.gni @@ -223,7 +223,7 @@ auto_filenames = { "lib/browser/api/views/image-view.ts", "lib/browser/api/web-contents-view.ts", "lib/browser/api/web-contents.js", - "lib/browser/chrome-extension-shim.js", + "lib/browser/chrome-extension-shim.ts", "lib/browser/default-menu.ts", "lib/browser/desktop-capturer.ts", "lib/browser/devtools.ts", diff --git a/lib/browser/chrome-extension-shim.js b/lib/browser/chrome-extension-shim.ts similarity index 86% rename from lib/browser/chrome-extension-shim.js rename to lib/browser/chrome-extension-shim.ts index 48919f5160..0d782fded3 100644 --- a/lib/browser/chrome-extension-shim.js +++ b/lib/browser/chrome-extension-shim.ts @@ -1,23 +1,21 @@ -'use strict'; - // This is a temporary shim to aid in transition from the old // BrowserWindow-based extensions stuff to the new native-backed extensions // API. -const { app, session, BrowserWindow, deprecate } = require('electron'); +import { app, session, BrowserWindow, deprecate } from 'electron'; app.whenReady().then(function () { - const addExtension = function (srcDirectory) { + const addExtension = function (srcDirectory: string) { return session.defaultSession.loadExtension(srcDirectory); }; - const removeExtension = function (name) { + const removeExtension = function (name: string) { const extension = session.defaultSession.getAllExtensions().find(e => e.name === name); if (extension) { session.defaultSession.removeExtension(extension.id); } }; const getExtensions = function () { - const extensions = {}; + const extensions: Record = {}; session.defaultSession.getAllExtensions().forEach(e => { extensions[e.name] = e; }); diff --git a/lib/common/api/deprecate.ts b/lib/common/api/deprecate.ts index 4a3e4fea80..7d9fa9fb15 100644 --- a/lib/common/api/deprecate.ts +++ b/lib/common/api/deprecate.ts @@ -55,12 +55,12 @@ const deprecate: ElectronInternal.DeprecationUtil = { }; }, - moveAPI: (fn: Function, oldUsage: string, newUsage: string) => { + moveAPI (fn: T, oldUsage: string, newUsage: string): T { const warn = warnOnce(oldUsage, newUsage); return function (this: any) { warn(); return fn.apply(this, arguments); - }; + } as any; }, // change the name of an event diff --git a/typings/internal-electron.d.ts b/typings/internal-electron.d.ts index 9557d03d60..2f6384e7b6 100644 --- a/typings/internal-electron.d.ts +++ b/typings/internal-electron.d.ts @@ -147,7 +147,7 @@ declare namespace ElectronInternal { event(emitter: NodeJS.EventEmitter, oldName: string, newName: string): void; removeProperty(object: T, propertyName: K, onlyForValues?: any[]): T; renameProperty(object: T, oldName: string, newName: K): T; - moveAPI(fn: Function, oldUsage: string, newUsage: string): Function; + moveAPI(fn: T, oldUsage: string, newUsage: string): T; } interface DesktopCapturer {