question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript issues with Electron 15.x and 2.0.1

See original GitHub issue

Receiving build errors in my electron project. It appears as though there are errors in the types files between the native electron resources and this expansion lib mappings. Anyone else seeing this issue, or any guidance on correcting the issue?

(ex1)

Error: node_modules/@electron/remote/index.d.ts:8:43 - error TS2339: Property 'ClientRequest' does not 
exist on type 'typeof CrossProcessExports'.

8 export var ClientRequest: typeof Electron.ClientRequest;

(ex2)

Error: node_modules/@electron/remote/index.d.ts:10:41 - error TS2339: Property 'CommandLine' does not
 exist on type 'typeof CrossProcessExports'.

10 export var CommandLine: typeof Electron.CommandLine;

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:7

github_iconTop GitHub Comments

4reactions
k8stonecommented, Nov 11, 2021

The following replacement for index.d.ts appears to resolve the issue for me while also working for Electron 14.x, but I’m not familiar enough with the @electron/remote project to have confidence that this is the appropriate fix for a pull request:

import * as Electron from ‘electron’;

// Taken from RemoteMainInterface 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: Electron.ClientRequest; export var clipboard: Electron.Clipboard; export var CommandLine: Electron.CommandLine; export var contentTracing: Electron.ContentTracing; export var Cookies: Electron.Cookies; export var crashReporter: Electron.CrashReporter; export var Debugger: Electron.Debugger; export var desktopCapturer: Electron.DesktopCapturer; export var dialog: Electron.Dialog; export var Dock: Electron.Dock; export var DownloadItem: Electron.DownloadItem; export var globalShortcut: Electron.GlobalShortcut; export var inAppPurchase: Electron.InAppPurchase; export var IncomingMessage: 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: 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: 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: Electron.TouchBarButton; export var TouchBarColorPicker: Electron.TouchBarColorPicker; export var TouchBarGroup: Electron.TouchBarGroup; export var TouchBarLabel: Electron.TouchBarLabel; export var TouchBarOtherItemsProxy: Electron.TouchBarOtherItemsProxy; export var TouchBarPopover: Electron.TouchBarPopover; export var TouchBarScrubber: Electron.TouchBarScrubber; export var TouchBarSegmentedControl: Electron.TouchBarSegmentedControl; export var TouchBarSlider: Electron.TouchBarSlider; export var TouchBarSpacer: Electron.TouchBarSpacer; export var Tray: typeof Electron.Tray; export var webContents: typeof Electron.webContents; export var WebRequest: 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;

3reactions
Farmers-Tyler-Doughertycommented, Oct 6, 2021

Downgraded to electron 14.1.0 and project builds correctly. You appear to have an undocumented compatibility issue with Electron 15.x.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why doesn't electron 2.0 support TypeScript (ES6) import?
This 2 year old answer states the reason is dependent components (nodejs and chrome) don't support it, which is no longer true, so...
Read more >
TypeScript - Wikipedia
TypeScript is a free and open source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and...
Read more >
Announcing TypeScript support in Electron
The electron npm package now includes a TypeScript definition file that provides detailed annotations of the entire Electron API.
Read more >
@electron/remote - npm
Start using @electron/remote in your project by running `npm i ... TypeScript icon, indicating that this package has built-in type ...
Read more >
electron-forge/template-typescript-webpack - Yarn
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found