fix: type internal APIs that can return null properly (#29852)

This commit is contained in:
Milan Burda 2021-07-27 07:48:12 +02:00 committed by GitHub
parent 461db8f1ab
commit a545cd3790
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 12 deletions

View file

@ -28,7 +28,7 @@ const getGuestWindow = function (guestContents: WebContents) {
};
const isChildWindow = function (sender: WebContents, target: WebContents) {
return target.getLastWebPreferences().openerId === sender.id;
return target.getLastWebPreferences()!.openerId === sender.id;
};
const isRelatedWindow = function (sender: WebContents, target: WebContents) {
@ -43,7 +43,7 @@ const isScriptableWindow = function (sender: WebContents, target: WebContents) {
};
const isNodeIntegrationEnabled = function (sender: WebContents) {
return sender.getLastWebPreferences().nodeIntegration === true;
return sender.getLastWebPreferences()!.nodeIntegration === true;
};
// Checks whether |sender| can access the |target|:
@ -65,7 +65,7 @@ ipcMainInternal.on(
features: string
) => {
// This should only be allowed for senders that have nativeWindowOpen: false
const lastWebPreferences = event.sender.getLastWebPreferences();
const lastWebPreferences = event.sender.getLastWebPreferences()!;
if (lastWebPreferences.nativeWindowOpen || lastWebPreferences.sandbox) {
event.returnValue = null;
throw new Error(