Raphael10
Raphael10

Reputation: 3096

How to close BrowserView / BrowserWindow 's WebContents in Electron?

How to destroy / close BrowserView / BrowserWindow 's WebContents ?

I tried to use, as suggested here: https://github.com/electron/electron/issues/26929 destroy() but I get

TS2339: Property 'destroy' does not exist on type 'WebContents'

Upvotes: 1

Views: 1415

Answers (1)

pushkin
pushkin

Reputation: 10209

That's just because the destroy method wasn't added to the typings since it's meant to be an undocumented, internal function.

Notice, the error you're getting is a Typescript compilation error, not a runtime error.

Type assert to any and it should work: (webContents as any).destroy()

Upvotes: 2

Related Questions