electron-userland / spectron

DEPRECATED: 🔎 Test Electron apps using ChromeDriver
http://electronjs.org/spectron
MIT License
1.68k stars 229 forks source link

Missing Promise for {electron, browserWindow, webContents} types #998

Open andersk opened 3 years ago

andersk commented 3 years ago

The spectron TypeScript declarations copy the RemoteMainInterface, BrowserWindow, WebContents types from electron, but this leads to incorrect type errors because spectron changes all the methods on these interfaces return Promises.

For example, given

import electronPath from "electron";
import { Application } from "spectron";

const app = new Application({
  path: electronPath as unknown as string,
  args: ["./app"],
});

app.start().then(() =>
  app.browserWindow.isVisible().then((visible: boolean) => {
    console.log(visible);
    app.stop();
  })
);

TypeScript complains:

test.ts:10:33 - error TS2339: Property 'then' does not exist on type 'boolean'.

10   app.browserWindow.isVisible().then((visible: boolean) => {
                                   ~~~~

Found 1 error.