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.
The
spectron
TypeScript declarations copy theRemoteMainInterface
,BrowserWindow
,WebContents
types fromelectron
, but this leads to incorrect type errors becausespectron
changes all the methods on these interfaces returnPromise
s.For example, given
TypeScript complains: