Skip to content

[node] zlib: Add ZIP archive API - #75745

Open
sigv wants to merge 1 commit into
DefinitelyTyped:masterfrom
sigv:node/zlib-zip-api
Open

sigv wants to merge 1 commit into
DefinitelyTyped:masterfrom
sigv:node/zlib-zip-api

Conversation

@sigv

@sigv sigv commented Oct 7, 2026

Copy link
Copy Markdown

Node.js v26.8.0 (2026-08-26) added a ZIP archive API to node:zlib:

  • zlib.ZipBuffer
  • zlib.ZipEntry
  • zlib.ZipFile
  • zlib.createZipArchive()
  • zlib.createZipArchiveSync()
  • zlib.zipFiles()
  • zlib.getMaxZipContentSize()
  • zlib.setMaxZipContentSize()

This API allows developers to work with ZIP archives without having to install third-party packages. Even though the API is marked as "1.0 - Early development", developers want to experiment with this functionality - myself included.

The implementation is still under active development. Therefore typing adheres to documentation and not source code, except for where the docs are silent and additional insights are needed (callback parameters for forEach()/forEachSync() where docs just state {Function}). Using documentation as the primary source also allows us to follow a simple rule-based approach: when the docs change, the types change.

In turn we must accept that in some situations, typing will be stricter than the underlying source code may currently permit. For example:

  • zipFiles() accepts an async iterable at runtime, even though docs only list a sync Iterable;
  • ZipFile works with await using / using at runtime, due to an undocumented Symbol.asyncDispose / Symbol.dispose;
  • ZipFile is iterable at runtime with differing behavior between sync ([name, Promise<ZipEntry>] pair) and async (plain resolved ZipEntry) iterators, which the docs don't mention.

To clearly denote that the API behavior may change, the new classes and functions all carry an @experimental tag.

Precedent for typing early-development APIs already exists:

  • node:test mock.module() has the Stability 1.0 designation;
  • node:test Test tags carry the Stability 1.0 designation;
  • node:quic module as a whole has the Stability 1.0 designation.

Other v26.7/v26.8 changes are not included, as the scope of the change is only adding the ZIP archive API. As a result, the overall package version is not bumped.


If changing an existing definition:

Node.js v26.8.0 (2026-08-26) added a ZIP archive API to `node:zlib`:
* `zlib.ZipBuffer`
* `zlib.ZipEntry`
* `zlib.ZipFile`
* `zlib.createZipArchive()`
* `zlib.createZipArchiveSync()`
* `zlib.zipFiles()`
* `zlib.getMaxZipContentSize()`
* `zlib.setMaxZipContentSize()`

This API allows developers to work with ZIP archives without having
to install third-party packages. Even though the API is marked as
"1.0 - Early development", developers want to experiment with this
functionality - myself included.

The implementation is still under active development. Therefore typing
adheres to documentation and not source code, except for where the docs
are silent and additional insights are needed (callback parameters for
`forEach()`/`forEachSync()` where docs just state `{Function}`). Using
documentation as the primary source also allows us to follow a simple
rule-based approach: when the docs change, the types change.

In turn we must accept that in some situations, typing will be stricter
than the underlying source code may currently permit. For example:
* `zipFiles()` accepts an async iterable at runtime, even though docs
  only list a sync `Iterable`;
* `ZipFile` works with `await using` / `using` at runtime, due to an
  undocumented `Symbol.asyncDispose` / `Symbol.dispose`;
* `ZipFile` is iterable at runtime with differing behavior between
  sync (`[name, Promise<ZipEntry>]` pair) and async (plain resolved
  `ZipEntry`) iterators, which the docs don't mention.

To clearly denote that the API behavior may change, the new classes and
functions all carry an `@experimental` tag.

Precedent for typing early-development APIs already exists:
* `node:test` `mock.module()` has the Stability 1.0 designation;
* `node:test` Test tags carry the Stability 1.0 designation;
* `node:quic` module as a whole has the Stability 1.0 designation.

Other v26.7/v26.8 changes are not included, as the scope of the change
is only adding the ZIP archive API. As a result, the overall package
version is not bumped.
@typescript-automation

typescript-automation Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

@sigv Thank you for submitting this PR!

This is a live comment that I will keep updated.

1 package in this PR

Code Reviews

Because this is a widely-used package, a DT maintainer will need to review it before it can be merged.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • 🕐 Most recent commit is approved by a DT maintainer

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 75745,
  "author": "sigv",
  "headCommitOid": "2bd2d0deb50156888551daa6b0292951508deaaa",
  "mergeBaseOid": "73df926871e11d055f6a97d583eb17e220a8c819",
  "lastPushDate": "2026-10-07T14:46:27.000Z",
  "lastActivityDate": "2026-10-07T15:30:37.000Z",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "tooManyCommits": false,
  "tooManyReviews": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "node",
      "version": "26.6",
      "kind": "edit",
      "files": [
        {
          "path": "types/node/node-tests/zlib.ts",
          "kind": "test"
        },
        {
          "path": "types/node/zlib.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "Microsoft",
        "jkomyno",
        "r3nya",
        "btoueg",
        "touffy",
        "mohsen1",
        "galkin",
        "eps1lon",
        "WilcoBakker",
        "trivikr",
        "yoursunny",
        "ExE-Boss",
        "peterblazejewicz",
        "addaleax",
        "NodeJS",
        "LinusU",
        "wafuwafu13",
        "mcollina",
        "Semigradsky",
        "Renegade334",
        "anonrig"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [],
  "mainBotCommentID": 6040469599,
  "ciResult": "pass"
}

@typescript-automation

Copy link
Copy Markdown
Contributor

🔔 @microsoft @jkomyno @r3nya @btoueg @Touffy @mohsen1 @galkin @eps1lon @WilcoBakker @trivikr @yoursunny @ExE-Boss @peterblazejewicz @addaleax @nodejs @LinusU @wafuwafu13 @mcollina @Semigradsky @Renegade334 @anonrig — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@sigv

sigv commented Oct 7, 2026

Copy link
Copy Markdown
Author

In-line documentation is pulled from upstream docs/api/zlib.md.

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

Projects

Status: Needs Maintainer Review

Development

Successfully merging this pull request may close these issues.

1 participant