typings: share AsyncWrap and HandleWrap types

Add reusable AsyncWrap and HandleWrap interfaces and use them for
signal_wrap and watchdog typings.

This reflects the native inheritance hierarchy and exposes AsyncWrap
methods that are already available at runtime.

Signed-off-by: leah-1ee <selee3196@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66150
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Seongeun Lee authored and Antoine du Hamel committed 2026-11-11 17:27:34 +01:00
1 parent 56471e45c2
commit 7c62da0585
4 files changed
+23 -8

No files matched your search

+7
View File
@@ -1,5 +1,12 @@
import { owner_symbol } from './symbols';
export interface AsyncWrap {
getAsyncId(): number;
asyncReset(resource: object, executionAsyncId?: number): void;
getAsyncContextFrameForDebuggingOnly(): unknown;
getProviderType(): number;
}
declare namespace InternalAsyncWrapBinding {
interface Resource {
[owner_symbol]?: PublicResource;
+8
View File
@@ -0,0 +1,8 @@
import type { AsyncWrap } from './async_wrap';
export interface HandleWrap extends AsyncWrap {
close(callback?: () => void): void;
hasRef(): boolean;
ref(): void;
unref(): void;
}
+4 -4
View File
@@ -1,14 +1,14 @@
import type { HandleWrap } from './handle_wrap';
declare namespace InternalSignalWrapBinding {
class Signal {
constructor();
onsignal?: (signum: number) => void;
start(signum: number): number | undefined;
stop(): number;
close(callback?: () => void): void;
hasRef(): boolean;
ref(): void;
unref(): void;
}
interface Signal extends HandleWrap {}
}
export interface SignalWrapBinding {
+4 -4
View File
@@ -1,13 +1,13 @@
import type { HandleWrap } from './handle_wrap';
declare namespace InternalWatchdogBinding {
class TraceSigintWatchdog {
constructor();
start(): void;
stop(): void;
close(callback?: () => void): void;
hasRef(): boolean;
ref(): void;
unref(): void;
}
interface TraceSigintWatchdog extends HandleWrap {}
}
export interface WatchdogBinding {