refactor: replace a few any-s with proper types (#25681)
This commit is contained in:
parent
603f9242d9
commit
fb11a12d5b
19 changed files with 170 additions and 53 deletions
116
typings/internal-ambient.d.ts
vendored
116
typings/internal-ambient.d.ts
vendored
|
@ -92,6 +92,11 @@ declare namespace NodeJS {
|
|||
initAsarSupport(require: NodeJS.Require): void;
|
||||
}
|
||||
|
||||
interface PowerMonitorBinding extends Electron.PowerMonitor {
|
||||
createPowerMonitor(): PowerMonitorBinding;
|
||||
setListeningForShutdown(listening: boolean): void;
|
||||
}
|
||||
|
||||
type DataPipe = {
|
||||
write: (buf: Uint8Array) => Promise<void>;
|
||||
done: () => void;
|
||||
|
@ -138,16 +143,51 @@ declare namespace NodeJS {
|
|||
}
|
||||
|
||||
interface Process {
|
||||
internalBinding?(name: string): any;
|
||||
_linkedBinding(name: string): any;
|
||||
_linkedBinding(name: 'electron_renderer_ipc'): { ipc: IpcRendererBinding };
|
||||
_linkedBinding(name: 'electron_common_v8_util'): V8UtilBinding;
|
||||
_linkedBinding(name: 'electron_common_features'): FeaturesBinding;
|
||||
_linkedBinding(name: 'electron_browser_app'): { app: Electron.App, App: Function };
|
||||
_linkedBinding(name: 'electron_common_asar'): AsarBinding;
|
||||
_linkedBinding(name: 'electron_common_clipboard'): Electron.Clipboard;
|
||||
_linkedBinding(name: 'electron_common_command_line'): Electron.CommandLine;
|
||||
_linkedBinding(name: 'electron_common_environment'): EnvironmentBinding;
|
||||
_linkedBinding(name: 'electron_common_features'): FeaturesBinding;
|
||||
_linkedBinding(name: 'electron_common_native_image'): { nativeImage: typeof Electron.NativeImage };
|
||||
_linkedBinding(name: 'electron_common_native_theme'): { nativeTheme: Electron.NativeTheme };
|
||||
_linkedBinding(name: 'electron_common_notification'): {
|
||||
isSupported(): boolean;
|
||||
Notification: typeof Electron.Notification;
|
||||
}
|
||||
_linkedBinding(name: 'electron_common_screen'): { createScreen(): Electron.Screen };
|
||||
_linkedBinding(name: 'electron_common_shell'): Electron.Shell;
|
||||
_linkedBinding(name: 'electron_common_v8_util'): V8UtilBinding;
|
||||
_linkedBinding(name: 'electron_browser_app'): { app: Electron.App, App: Function };
|
||||
_linkedBinding(name: 'electron_browser_auto_updater'): { autoUpdater: Electron.AutoUpdater };
|
||||
_linkedBinding(name: 'electron_browser_browser_view'): { BrowserView: typeof Electron.BrowserView };
|
||||
_linkedBinding(name: 'electron_browser_crash_reporter'): Omit<Electron.CrashReporter, 'start'> & {
|
||||
start(submitUrl: string,
|
||||
uploadToServer: boolean,
|
||||
ignoreSystemCrashHandler: boolean,
|
||||
rateLimit: boolean,
|
||||
compress: boolean,
|
||||
globalExtra: Record<string, string>,
|
||||
extra: Record<string, string>,
|
||||
isNodeProcess: boolean): void;
|
||||
};
|
||||
_linkedBinding(name: 'electron_browser_desktop_capturer'): {
|
||||
createDesktopCapturer(): ElectronInternal.DesktopCapturer;
|
||||
};
|
||||
_linkedBinding(name: 'electron_browser_event'): {
|
||||
createWithSender(sender: Electron.WebContents): Electron.Event;
|
||||
createEmpty(): Electron.Event;
|
||||
};
|
||||
_linkedBinding(name: 'electron_browser_event_emitter'): {
|
||||
setEventEmitterPrototype(prototype: Object): void;
|
||||
};
|
||||
_linkedBinding(name: 'electron_browser_global_shortcut'): { globalShortcut: Electron.GlobalShortcut };
|
||||
_linkedBinding(name: 'electron_browser_image_view'): { ImageView: any };
|
||||
_linkedBinding(name: 'electron_browser_in_app_purchase'): { inAppPurchase: Electron.InAppPurchase };
|
||||
_linkedBinding(name: 'electron_browser_message_port'): {
|
||||
createPair(): { port1: Electron.MessagePortMain, port2: Electron.MessagePortMain };
|
||||
};
|
||||
_linkedBinding(name: 'electron_browser_net'): {
|
||||
isValidHeaderName: (headerName: string) => boolean;
|
||||
isValidHeaderValue: (headerValue: string) => boolean;
|
||||
|
@ -155,7 +195,15 @@ declare namespace NodeJS {
|
|||
net: any;
|
||||
createURLLoader(options: CreateURLLoaderOptions): URLLoader;
|
||||
};
|
||||
_linkedBinding(name: 'electron_common_asar'): AsarBinding;
|
||||
_linkedBinding(name: 'electron_browser_power_monitor'): PowerMonitorBinding;
|
||||
_linkedBinding(name: 'electron_browser_power_save_blocker'): { powerSaveBlocker: Electron.PowerSaveBlocker };
|
||||
_linkedBinding(name: 'electron_browser_session'): typeof Electron.Session;
|
||||
_linkedBinding(name: 'electron_browser_system_preferences'): { systemPreferences: Electron.SystemPreferences };
|
||||
_linkedBinding(name: 'electron_browser_tray'): { Tray: Electron.Tray };
|
||||
_linkedBinding(name: 'electron_browser_view'): { View: Electron.View };
|
||||
_linkedBinding(name: 'electron_browser_web_contents_view'): { WebContentsView: typeof Electron.WebContentsView };
|
||||
_linkedBinding(name: 'electron_renderer_crash_reporter'): Electron.CrashReporter;
|
||||
_linkedBinding(name: 'electron_renderer_ipc'): { ipc: IpcRendererBinding };
|
||||
log: NodeJS.WriteStream['write'];
|
||||
activateUvLoop(): void;
|
||||
|
||||
|
@ -259,3 +307,61 @@ interface ResizeObserverEntry {
|
|||
*/
|
||||
readonly contentRect: DOMRectReadOnly;
|
||||
}
|
||||
|
||||
// https://github.com/microsoft/TypeScript/pull/38232
|
||||
|
||||
interface WeakRef<T extends object> {
|
||||
readonly [Symbol.toStringTag]: "WeakRef";
|
||||
|
||||
/**
|
||||
* Returns the WeakRef instance's target object, or undefined if the target object has been
|
||||
* reclaimed.
|
||||
*/
|
||||
deref(): T | undefined;
|
||||
}
|
||||
|
||||
interface WeakRefConstructor {
|
||||
readonly prototype: WeakRef<any>;
|
||||
|
||||
/**
|
||||
* Creates a WeakRef instance for the given target object.
|
||||
* @param target The target object for the WeakRef instance.
|
||||
*/
|
||||
new<T extends object>(target?: T): WeakRef<T>;
|
||||
}
|
||||
|
||||
declare var WeakRef: WeakRefConstructor;
|
||||
|
||||
interface FinalizationRegistry {
|
||||
readonly [Symbol.toStringTag]: "FinalizationRegistry";
|
||||
|
||||
/**
|
||||
* Registers an object with the registry.
|
||||
* @param target The target object to register.
|
||||
* @param heldValue The value to pass to the finalizer for this object. This cannot be the
|
||||
* target object.
|
||||
* @param unregisterToken The token to pass to the unregister method to unregister the target
|
||||
* object. If provided (and not undefined), this must be an object. If not provided, the target
|
||||
* cannot be unregistered.
|
||||
*/
|
||||
register(target: object, heldValue: any, unregisterToken?: object): void;
|
||||
|
||||
/**
|
||||
* Unregisters an object from the registry.
|
||||
* @param unregisterToken The token that was used as the unregisterToken argument when calling
|
||||
* register to register the target object.
|
||||
*/
|
||||
unregister(unregisterToken: object): void;
|
||||
}
|
||||
|
||||
interface FinalizationRegistryConstructor {
|
||||
readonly prototype: FinalizationRegistry;
|
||||
|
||||
/**
|
||||
* Creates a finalization registry with an associated cleanup callback
|
||||
* @param cleanupCallback The callback to call after an object in the registry has been reclaimed.
|
||||
*/
|
||||
new(cleanupCallback: (heldValue: any) => void): FinalizationRegistry;
|
||||
}
|
||||
|
||||
declare var FinalizationRegistry: FinalizationRegistryConstructor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue