Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should getFocusedWebContents() have return type 'WebContents | null'? #202

Closed
kevinushey opened this issue Mar 4, 2022 · 4 comments
Closed

Comments

@kevinushey
Copy link

kevinushey commented Mar 4, 2022

My electron.d.ts (from version 17.1.0) has:

    /**
     * The web contents that is focused in this application, otherwise returns `null`.
     */
    static getFocusedWebContents(): WebContents;

IIUC, because this function can return null, the return value should be declared as WebContents | null. Or am I misunderstanding something?

@erickzhao
Copy link
Member

I think you're right. This should be fixed in the documentation itself over in the main Electron repo. :)

@kevinushey
Copy link
Author

Thanks! It wasn't quite clear to me where and how electron.d.ts is generated, so I filed the issue here first -- should I close this and re-open at https://github.com/electron/electron/issues?

@erickzhao
Copy link
Member

erickzhao commented Mar 7, 2022

Feel free to make a documentation PR directly. It should look something like this:

In docs/api/web-contents.md

- Returns `WebContents` - The web contents that is focused in this application, otherwise
+ Returns `WebContents` | null - The web contents that is focused in this application, otherwise
returns `null`.

@kevinushey
Copy link
Author

Thank you :-) I'll do that!

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

No branches or pull requests

2 participants