From f7c0a29d89155fff1f0a281f0cb6280c695707c8 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 14 Jun 2023 20:06:46 +0200 Subject: [PATCH] build: update to latest TypeScript (#38763) --- lib/browser/guest-view-manager.ts | 4 ++-- lib/common/deprecate.ts | 2 +- lib/renderer/init.ts | 5 ++++- lib/renderer/window-setup.ts | 2 +- lib/sandboxed_renderer/init.ts | 12 +++++++++++- package.json | 2 +- yarn.lock | 8 ++++---- 7 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/browser/guest-view-manager.ts b/lib/browser/guest-view-manager.ts index 03f786a30a00..eda3d9aff52a 100644 --- a/lib/browser/guest-view-manager.ts +++ b/lib/browser/guest-view-manager.ts @@ -8,7 +8,7 @@ import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; interface GuestInstance { elementInstanceId: number; - visibilityState?: VisibilityState; + visibilityState?: DocumentVisibilityState; embedder: Electron.WebContents; guest: Electron.WebContents; } @@ -229,7 +229,7 @@ const watchEmbedder = function (embedder: Electron.WebContents) { watchedEmbedders.add(embedder); // Forward embedder window visibility change events to guest - const onVisibilityChange = function (visibilityState: VisibilityState) { + const onVisibilityChange = function (visibilityState: DocumentVisibilityState) { for (const guestInstance of guestInstances.values()) { guestInstance.visibilityState = visibilityState; if (guestInstance.embedder === embedder) { diff --git a/lib/common/deprecate.ts b/lib/common/deprecate.ts index 5d71548561ad..94f2e80acd59 100644 --- a/lib/common/deprecate.ts +++ b/lib/common/deprecate.ts @@ -110,7 +110,7 @@ export function removeProperty(object: T, remov } // change the name of a property -export function renameProperty(object: T, oldName: string, newName: K): T { +export function renameProperty(object: T, oldName: string, newName: K): T { const warn = warnOnce(oldName, newName); // if the new property isn't there yet, diff --git a/lib/renderer/init.ts b/lib/renderer/init.ts index c8fb8bcfb7e2..6abdfe027db4 100644 --- a/lib/renderer/init.ts +++ b/lib/renderer/init.ts @@ -122,7 +122,10 @@ if (nodeIntegration) { } } -const { preloadPaths } = ipcRendererUtils.invokeSync(IPC_MESSAGES.BROWSER_NONSANDBOX_LOAD); +const { preloadPaths } = ipcRendererUtils.invokeSync<{ + preloadPaths: string[] +}>(IPC_MESSAGES.BROWSER_NONSANDBOX_LOAD); + // Load the preload scripts. for (const preloadScript of preloadPaths) { try { diff --git a/lib/renderer/window-setup.ts b/lib/renderer/window-setup.ts index 6c9f15a2d418..9dc539edb6a5 100644 --- a/lib/renderer/window-setup.ts +++ b/lib/renderer/window-setup.ts @@ -30,7 +30,7 @@ export const windowSetup = (isWebView: boolean, isHiddenPage: boolean) => { let cachedVisibilityState = isHiddenPage ? 'hidden' : 'visible'; // Subscribe to visibilityState changes. - ipcRendererInternal.on(IPC_MESSAGES.GUEST_INSTANCE_VISIBILITY_CHANGE, function (_event, visibilityState: VisibilityState) { + ipcRendererInternal.on(IPC_MESSAGES.GUEST_INSTANCE_VISIBILITY_CHANGE, function (_event, visibilityState: DocumentVisibilityState) { if (cachedVisibilityState !== visibilityState) { cachedVisibilityState = visibilityState; document.dispatchEvent(new Event('visibilitychange')); diff --git a/lib/sandboxed_renderer/init.ts b/lib/sandboxed_renderer/init.ts index 913b57480c6c..555c7d35cdcd 100644 --- a/lib/sandboxed_renderer/init.ts +++ b/lib/sandboxed_renderer/init.ts @@ -30,7 +30,17 @@ Object.setPrototypeOf(process, EventEmitter.prototype); const { ipcRendererInternal } = require('@electron/internal/renderer/ipc-renderer-internal') as typeof ipcRendererInternalModule; const ipcRendererUtils = require('@electron/internal/renderer/ipc-renderer-internal-utils') as typeof ipcRendererUtilsModule; -const { preloadScripts, process: processProps } = ipcRendererUtils.invokeSync(IPC_MESSAGES.BROWSER_SANDBOX_LOAD); +const { + preloadScripts, + process: processProps +} = ipcRendererUtils.invokeSync<{ + preloadScripts: { + preloadPath: string; + preloadSrc: string | null; + preloadError: null | Error; + }[]; + process: NodeJS.Process; +}>(IPC_MESSAGES.BROWSER_SANDBOX_LOAD); const electron = require('electron'); diff --git a/package.json b/package.json index cda8388fc2f6..58738bfebc86 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "timers-browserify": "1.4.2", "ts-loader": "^8.0.2", "ts-node": "6.2.0", - "typescript": "^4.5.5", + "typescript": "^5.1.2", "url": "^0.11.0", "webpack": "^5.76.0", "webpack-cli": "^4.10.0", diff --git a/yarn.lock b/yarn.lock index 6cc2cc1d5ee8..71750a10987e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6645,10 +6645,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^4.5.5: - version "4.5.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3" - integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA== +typescript@^5.1.2: + version "5.1.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.3.tgz#8d84219244a6b40b6fb2b33cc1c062f715b9e826" + integrity sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw== uc.micro@^1.0.1, uc.micro@^1.0.5: version "1.0.6"