Skip to content

Commit 44ff2db

Browse files
authored
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: #66150 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 1eacebb commit 44ff2db

4 files changed

Lines changed: 23 additions & 8 deletions

File tree

‎typings/internalBinding/async_wrap.d.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { owner_symbol } from './symbols';
22

3+
export interface AsyncWrap {
4+
getAsyncId(): number;
5+
asyncReset(resource: object, executionAsyncId?: number): void;
6+
getAsyncContextFrameForDebuggingOnly(): unknown;
7+
getProviderType(): number;
8+
}
9+
310
declare namespace InternalAsyncWrapBinding {
411
interface Resource {
512
[owner_symbol]?: PublicResource;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { AsyncWrap } from './async_wrap';
2+
3+
export interface HandleWrap extends AsyncWrap {
4+
close(callback?: () => void): void;
5+
hasRef(): boolean;
6+
ref(): void;
7+
unref(): void;
8+
}

‎typings/internalBinding/signal_wrap.d.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import type { HandleWrap } from './handle_wrap';
2+
13
declare namespace InternalSignalWrapBinding {
24
class Signal {
35
constructor();
46
onsignal?: (signum: number) => void;
57
start(signum: number): number | undefined;
68
stop(): number;
7-
close(callback?: () => void): void;
8-
hasRef(): boolean;
9-
ref(): void;
10-
unref(): void;
119
}
10+
11+
interface Signal extends HandleWrap {}
1212
}
1313

1414
export interface SignalWrapBinding {

‎typings/internalBinding/watchdog.d.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import type { HandleWrap } from './handle_wrap';
2+
13
declare namespace InternalWatchdogBinding {
24
class TraceSigintWatchdog {
35
constructor();
46
start(): void;
57
stop(): void;
6-
close(callback?: () => void): void;
7-
hasRef(): boolean;
8-
ref(): void;
9-
unref(): void;
108
}
9+
10+
interface TraceSigintWatchdog extends HandleWrap {}
1111
}
1212

1313
export interface WatchdogBinding {

0 commit comments

Comments
 (0)