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

[Feature Request] TypeScript definitions for window.chrome.webview #4194

Open
victorhuangwq opened this issue Nov 27, 2023 Discussed in #4028 · 0 comments
Open

[Feature Request] TypeScript definitions for window.chrome.webview #4194

victorhuangwq opened this issue Nov 27, 2023 Discussed in #4028 · 0 comments
Assignees
Labels
feature request feature request tracked We are tracking this work internally.

Comments

@victorhuangwq
Copy link
Collaborator

victorhuangwq commented Nov 27, 2023

Describe the feature/enhancement you need
Global TypeScript Interface for window.chrome.webview

The scenario/use case where you would use this feature
When developing using Typescript while using WebView2

Refer to the discussion for further context.

Discussed in #4028

Originally posted by danbahrami March 7, 2023
Hi, I'm looking through the WebView2 docs and can't find any API reference for window.chrome.webview. Specifically I'm looking to define a global TypeScript interface for window.chrome.webview.postMessage and window.chrome.webview.addEventListener.

I have a couple of questions:

1. What's the method for removing event listeners?

I can't tell if window.chrome.addEventListener returns an unsubscribe callback or if there's an adjacent removeEventListener that behaves the same as adding/removing DOM events.

2. Do you have a recommendation for a global TypeScript definition?

Here's what I've got so far but I'm not sure if it's accurate

declare global {
    interface Window {
        chrome?: {
            webview?: {
                addEventListener: (
                    message: string,
                    handler: (event: any) => void, // not sure yet what the event type should be
                ) => void;
                postMessage: (message: string) => void;
            };
        };
    }
}

AB#40423422

@victorhuangwq victorhuangwq changed the title [Feature RequestTypeScript definitions for window.chrome.webview [Feature Request] TypeScript definitions for window.chrome.webview Nov 27, 2023
@victorhuangwq victorhuangwq added feature request feature request tracked We are tracking this work internally. labels Nov 27, 2023
@victorhuangwq victorhuangwq self-assigned this Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request feature request tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

1 participant