Skip to content

Fix doc and type#897

Merged
VerteDinde merged 4 commits intoelectron-userland:masterfrom
mtgto:fix_doc_and_type
Sep 16, 2021
Merged

Fix doc and type#897
VerteDinde merged 4 commits intoelectron-userland:masterfrom
mtgto:fix_doc_and_type

Conversation

@mtgto
Copy link
Copy Markdown
Contributor

@mtgto mtgto commented Mar 13, 2021

  1. Fix old and broken urls of webdriver.io
  2. Fix sample code in README
  3. Fix type of SpectronWindow

2. helps some issues like #815, #831 .

3. fixes SpectronWindow type:

import { Application } from "spectron";
let app: Application;

// ... skip setup ...

app.client.getText('#error-alert'); // compile error
const windowCount: number = app.client.getWindowCount(); // compile error
const promisedWindowCount: Promise<number> = app.client.getWindowCount();

Comment on lines +121 to +127
export type SpectronWindow = {
[P in keyof Electron.BrowserWindow]: Electron.BrowserWindow[P] extends (
...args: infer A
) => infer R
? (...args: A) => Promise<R>
: undefined;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this more completely in #999, using Promise<R extends PromiseLike<infer T> ? T : R> to avoid doubly-wrapped Promises, and wrapping every module in Electron, not just BrowserWindow.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andersk Great works!

@VerteDinde VerteDinde merged commit 891321b into electron-userland:master Sep 16, 2021
@mtgto mtgto deleted the fix_doc_and_type branch October 3, 2021 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants