Skip to content

typings: update zlib binding declarations - #65639

Open
hyemimi wants to merge 1 commit into
nodejs:mainfrom
hyemimi:fix-zlib-binding-typings
Open

typings: update zlib binding declarations#65639
hyemimi wants to merge 1 commit into
nodejs:mainfrom
hyemimi:fix-zlib-binding-typings

Conversation

@hyemimi

@hyemimi hyemimi commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

This updates the zlib internal binding declarations to match the runtime exports from internalBinding('zlib').

The latest build exposes the following binding properties:

BrotliDecoder
BrotliEncoder
ZLIB_VERSION
Zlib
ZstdCompress
ZstdDecompress
crc32

typings/internalBinding/zlib.d.ts already declared BrotliDecoder, BrotliEncoder, and Zlib,
but was missing declarations for ZLIB_VERSION,ZstdCompress, ZstdDecompress, and crc32.

These exports are already registered by the native binding in src/node_zlib.cc:

MakeClass<ZstdCompressStream>::Make(env, target, "ZstdCompress");
MakeClass<ZstdDecompressStream>::Make(env, target, "ZstdDecompress");

SetFastMethodNoSideEffect(context, target, "crc32", CRC32, &fast_crc32_);

target->Set(env->context(),
            FIXED_ONE_BYTE_STRING(env->isolate(), "ZLIB_VERSION"),
            FIXED_ONE_BYTE_STRING(env->isolate(), ZLIB_VERSION)).Check();

They are also used by existing internal JavaScript consumers.
For example, lib/zlib.js reads crc32 from the binding:

const binding = internalBinding('zlib');
const { crc32: crc32Native } = binding;

and creates native zstd handles through the binding:

const handle = mode === ZSTD_COMPRESS ?
  new binding.ZstdCompress() : new binding.ZstdDecompress();

Adding these declarations keeps the internal binding typings aligned with the runtime exports and improves type checking for existing internal consumers.

Signed-off-by: hyemimi <hyemi7375@gmail.com>
@nodejs-github-bot nodejs-github-bot added the typings Issues and PRs related to internal TypeScript declarations. label Aug 29, 2026
@panva panva added author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 29, 2026
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. commit-queue PRs queued for automated landing through the Commit Queue. typings Issues and PRs related to internal TypeScript declarations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants