Skip to content

typings: share AsyncWrap and HandleWrap types - #66150

Open
leah-1ee wants to merge 1 commit into
nodejs:mainfrom
leah-1ee:typings-handle-wrap
Open

leah-1ee wants to merge 1 commit into
nodejs:mainfrom
leah-1ee:typings-handle-wrap

Conversation

@leah-1ee

@leah-1ee leah-1ee commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Some internal binding typings currently flatten methods inherited from native
base classes into each derived class.

For example, the native hierarchy for SignalWrap is:

Native class Direct JS-visible members
AsyncWrap getAsyncId, asyncReset, getAsyncContextFrameForDebuggingOnly, getProviderType
HandleWrap close, hasRef, ref, unref
SignalWrap start, stop

The current Signal typing directly declares the HandleWrap methods, while
the native inheritance relationship itself is not represented.

This change introduces reusable AsyncWrap and HandleWrap interfaces and
models the same hierarchy in the typings:

export interface AsyncWrap {
  getAsyncId(): number;
  asyncReset(resource: object, executionAsyncId?: number): void;
  getAsyncContextFrameForDebuggingOnly(): unknown;
  getProviderType(): number;
}

export interface HandleWrap extends AsyncWrap {
  close(callback?: () => void): void;
  hasRef(): boolean;
  ref(): void;
  unref(): void;
}

class Signal {
  constructor();
  onsignal?: (signum: number) => void;
  start(signum: number): number | undefined;
  stop(): number;
}

interface Signal extends HandleWrap {}

The same structure is applied to TraceSigintWatchdog.

This makes binding-specific members easier to distinguish from inherited
members and reduces repeated declarations.

No new runtime APIs are introduced. The AsyncWrap methods added to the
static types of Signal and TraceSigintWatchdog are already available
through the native prototype hierarchy.

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>
@nodejs-github-bot nodejs-github-bot added the typings Issues and PRs related to internal TypeScript declarations. label Sep 20, 2026
@leah-1ee
leah-1ee marked this pull request as ready for review September 20, 2026 07:15
Copilot AI lite review requested due to automatic review settings September 20, 2026 07:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typings Issues and PRs related to internal TypeScript declarations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants