-
Notifications
You must be signed in to change notification settings - Fork 63
TypeScript definitions for window.chrome.webview #3273
Copy link
Copy link
Closed
Description
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;
};
};
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels