Skip to content

typings: share AsyncWrap and HandleWrap types - #66150

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
leah-1ee:typings-handle-wrap
Sep 22, 2026
Merged

nodejs-github-bot merged 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.

@daeyeon daeyeon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As a follow-up, we could apply HandleWrap to other derived types as well.

@daeyeon daeyeon added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 21, 2026
@daeyeon daeyeon added the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 22, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 44ff2db into nodejs:main Sep 22, 2026
41 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 44ff2db

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 22, 2026
aduh95 pushed a commit that referenced this pull request Sep 27, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. typings Issues and PRs related to internal TypeScript declarations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants