chore: update to latest TypeScript, which has built-in WeakRef declarations (#27425)

This commit is contained in:
Milan Burda 2021-01-22 20:25:47 +01:00 committed by GitHub
parent fcdb7ad21a
commit 70190ec2b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 70 additions and 128 deletions

View file

@ -187,7 +187,7 @@ for (const method of webFrameMethods) {
const waitTillCanExecuteJavaScript = async (webContents: Electron.WebContents) => {
if (webContents.getURL() && !webContents.isLoadingMainFrame()) return;
return new Promise((resolve) => {
return new Promise<void>((resolve) => {
webContents.once('did-stop-loading', () => {
resolve();
});

View file

@ -62,7 +62,7 @@ const assertChromeDevTools = function (contents: Electron.WebContents, api: stri
};
ipcMainInternal.handle(IPC_MESSAGES.INSPECTOR_CONTEXT_MENU, function (event, items: ContextMenuItem[], isEditMenu: boolean) {
return new Promise(resolve => {
return new Promise<number | void>(resolve => {
assertChromeDevTools(event.sender, 'window.InspectorFrontendHost.showContextMenuAtPoint()');
const template = isEditMenu ? getEditMenuItems() : convertToMenuTemplate(items, resolve);

View file

@ -15,7 +15,7 @@ const { hasSwitch } = process._linkedBinding('electron_common_command_line');
const callbacksRegistry = new CallbacksRegistry();
const remoteObjectCache = new Map();
const finalizationRegistry = new (window as any).FinalizationRegistry((id: number) => {
const finalizationRegistry = new FinalizationRegistry((id: number) => {
const ref = remoteObjectCache.get(id);
if (ref !== undefined && ref.deref() === undefined) {
remoteObjectCache.delete(id);
@ -34,7 +34,7 @@ function getCachedRemoteObject (id: number) {
}
}
function setCachedRemoteObject (id: number, value: any) {
const wr = new (window as any).WeakRef(value);
const wr = new WeakRef(value);
remoteObjectCache.set(id, wr);
finalizationRegistry.register(value, id);
return value;