Skip to content

chore: generate types with the TypeScript CLI instead of tooling - #291

Merged
alexander-akait merged 2 commits into
mainfrom
claude/update-deps-github-actions-5ydose
Sep 25, 2026
Merged

alexander-akait merged 2 commits into
mainfrom
claude/update-deps-github-actions-5ydose

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

tooling is deprecated. This PR generates the type declarations with the TypeScript CLI, following webpack-dev-middleware, and keeps the package's public type exports the same.

How types are built

  • npm run build:types runs del-cli types && tsc -p tsconfig.types.json && prettier --write types. It emits one .d.ts per file in lib/ into a committed types/ folder. The clean step makes sure declarations for deleted files don't linger.
  • CI: the lint job rebuilds the types and fails if git status types shows changes.
  • Removed: the tooling dependency and the lint:special and fix:special scripts. fix now runs build:types.

Public entry (types.d.ts)

  • types.d.ts stays the package's types entry. It's now a short hand-written file that re-exports the generated declarations in the same shape as before:
    • all ten classes, usable as both values and types;
    • the same 14 helper types;
    • util.stringBufferUtils.
  • lint:types-test now type-checks it.
  • Why it's still needed: lib/index.js exports a frozen object of lazy getters, so the generated types/index.d.ts exposes the classes only as values. let s: Source wouldn't compile against it.
  • TODO: the file header notes that it should be removed in the next major, pointing types at types/index.d.ts once lib/index.js exports the classes as types too.
  • types/ is added to files.

@private tags removed from lib/ (JSDoc only, no runtime change)

  • Why: tsc emits @private members as TypeScript private members, and a class with private members only accepts instances from the same declaration file. Two installed copies of webpack-sources (e.g. webpack's and a plugin's), even the same version, would then reject each other's instances. Reproduced:
    Types have separate declarations of a private property '_source'.
    
  • The previous generator stripped these members. stripInternal has no effect on declarations emitted from JavaScript, so with plain tsc removing the tags is the only way to keep duplicate copies compatible.
  • Side effect: the @ts-expect-error above source._source in test/ReplaceSource.js became unused and is removed.

Differences in the published types

  • Internal _-prefixed class members (e.g. ReplaceSource._replacements) are now visible as ordinary members.
  • Replacement.name and Replacement.index are now string | undefined and number | undefined instead of optional, because a JavaScript class can't declare an optional field.
  • For overrides with the same signature as Source, tsc leaves the declaration out and it's inherited instead. The types are unchanged.
  • The inherit-types and format-file-header checks are removed along with tooling.

Compatibility with 3.5.2

  • Existing code: every export of the new types is assignable to the 3.5.2 types, so code written against them keeps compiling.
  • Base and helper types: Source, all helper types and util are identical in both directions.
  • Mixed versions: if a project mixes a 3.5.2 copy with a new copy, instances of the concrete classes from the old copy aren't assignable to the new copy's types, because the old types lack the _ members. Code typed against Source is unaffected.
  • Duplicate copies of the same version type-check as compatible.
  • Consumer check: installed the packed tarball in a fresh project and compiled a file using the whole API under node10, node16, nodenext and bundler resolution. Also type-checked webpack 5.111's declarations against it with skipLibCheck off.

Test plan

  • npm run lint (eslint, tsc, types test including types.d.ts)
  • npm run fmt:check
  • jest: 14 suites, 89,907 tests pass
  • npm run build:types on a clean tree produces no diff
  • CI stale-types check: passes on a clean tree; fails after a JSDoc edit without a rebuild (M types/RawSource.d.ts); fails after deleting a lib/ file (D types/helpers/getName.d.ts)

No changeset is included. The package now ships a types/ folder and its internal members are visible in the published types, so a patch changeset may be worth adding.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ThsbPWvW5vnYWEaFs2Q22F


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Added comprehensive TypeScript declarations for the source classes and related utilities, including source maps, streaming, caching, and string/buffer helpers.
    • Updated the package’s type entry point so TypeScript users can access the available classes and helper types.
  • Chores
    • Added a build check that reports an error when generated type declarations are out of date.

`tooling` is deprecated. Declarations are now emitted by `tsc` from the
JSDoc in `lib/` into `types/`, as in webpack-dev-middleware:

    npm run build:types
    # del-cli types && tsc -p tsconfig.types.json && prettier --write types

CI rebuilds them in the lint job and fails when the committed `types/`
are out of date.

`types.d.ts` stays the package's `types` entry and re-exports the
generated declarations in the same shape as before: every class as value
and type, the same helper types and `util.stringBufferUtils`. It is
type-checked by `lint:types-test`.

`@private` JSDoc tags are removed from `lib/` (no runtime change). `tsc`
emits them as `private` members, which makes TypeScript compare classes
nominally, so two installed copies of this package (even the same
version) would reject each other's instances. Without them the classes
stay structurally typed, as with the previous generated types.

The `inherit-types` and `format-file-header` checks are removed with
`tooling`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ThsbPWvW5vnYWEaFs2Q22F
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:

Co-authored-by: name <email>

Supported Co-authored-by: formats include:

  1. Anything <id+login@users.noreply.github.com> - it will locate your GitHub user by id part.
  2. Anything <login@users.noreply.github.com> - it will locate your GitHub user by login part.
  3. Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
  4. Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
  5. login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.

Alternatively, if the co-author should not be included, remove the Co-authored-by: line from the commit message.

Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:

/easycla

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addeddel-cli@​7.0.01001008081100

View full report

@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.30%. Comparing base (6f9c00e) to head (4b743c9).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #291   +/-   ##
=======================================
  Coverage   98.29%   98.30%           
=======================================
  Files          25       25           
  Lines        2289     2295    +6     
  Branches      735      737    +2     
=======================================
+ Hits         2250     2256    +6     
  Misses         37       37           
  Partials        2        2           
Flag Coverage Δ
integration 98.30% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed

codspeed Bot commented Sep 24, 2026

Copy link
Copy Markdown

Merging this PR will regress 8 benchmarks

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 12 improved benchmarks
❌ 8 regressed benchmarks
✅ 192 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory original-source memory: map({ columns: false }) line-only mappings 107.3 KB 383.1 KB -72%
❌ Memory compat-source memory: delegated source() + map() through wrapper 9.9 KB 30.9 KB -68.06%
❌ Memory cached-source memory: cold sourceAndMap() populates all caches 149.3 KB 194.7 KB -23.31%
❌ Memory concat-source memory: new ConcatSource(...children) 5.3 KB 6.7 KB -21.29%
❌ Memory raw-source memory: new RawSource(buffer) 1.3 KB 1.6 KB -18%
❌ Memory source-map-source memory: sourceAndMap({ columns: true }) (combined inner) 2.1 MB 2.4 MB -14.41%
❌ Memory original-source memory: new OriginalSource() 1.9 KB 2.2 KB -11.43%
❌ Simulation size-only-source: new SizeOnlySource() 325.4 µs 365.1 µs -10.87%
⚡ Memory clear-cache memory: shared modules (visited set — single allocation) 172,752 B 848 B ×200
⚡ Memory clear-cache memory: shared modules (no visited set — allocates per chunk) 814.6 KB 21.7 KB ×38
⚡ Memory replace-source memory: source() concatenates result 77.8 KB 6.2 KB ×13
⚡ Memory compat-source memory: new CompatSource(sourceLike) 3.9 KB 1.3 KB ×3
⚡ Memory replace-source memory: construct + 100 insertions 103.2 KB 37 KB ×2.8
⚡ Memory size-only-source memory: new SizeOnlySource() 207.7 KB 91.3 KB ×2.3
⚡ Memory source-map-source memory: new SourceMapSource(with inner map) 2.7 KB 1.3 KB ×2.1
⚡ Memory cached-source memory: construct from cachedData (no warm-up) 912 B 480 B +90%
⚡ Memory concat-source memory: source() concatenates children 198.7 KB 158.2 KB +25.63%
⚡ Memory raw-source memory: new RawSource(string) 1.5 KB 1.3 KB +19.51%
⚡ Memory cached-source memory: getCachedData() allocates BufferedMap 1,128 B 952 B +18.49%
⚡ Memory prefix-source memory: source() allocates rewritten string 2.2 KB 1.9 KB +14.52%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing claude/update-deps-github-actions-5ydose (4b743c9) with main (1c97070)

Open in CodSpeed

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Walkthrough

The change adds declaration files for source classes and helpers, and updates the package declaration entry points. It configures a command to generate and format declarations, includes the generated directory in package files, and adds a CI check for declaration changes. It also removes several @private JSDoc annotations and one test suppression comment. No runtime logic changes are described.

Merge Risk: 🟡 Moderate · up to 4b743

Consumers using older Node type declarations may be unable to type-check the package. Address the generated Buffer types before merging unless that compatibility break is explicitly accepted.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: replacing the tooling dependency with TypeScript CLI-based type generation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

package.json

ESLint failed to execute (timeout).

types.d.ts

ESLint skipped: the matched ESLint configuration already failed (timeout).

types/CachedSource.d.ts

ESLint skipped: the matched ESLint configuration already failed (timeout).

  • 24 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: ddbd1764-6fec-4598-864a-c69e04358754

📥 Commits

Reviewing files that changed from the base of the PR and between 1c97070 and 4b743c9.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (40)
  • .github/workflows/test.yml
  • lib/CachedSource.js
  • lib/CompatSource.js
  • lib/ConcatSource.js
  • lib/OriginalSource.js
  • lib/PrefixSource.js
  • lib/RawSource.js
  • lib/ReplaceSource.js
  • lib/SizeOnlySource.js
  • lib/SourceMapSource.js
  • package.json
  • test/ReplaceSource.js
  • tsconfig.types.json
  • tsconfig.types.test.json
  • types.d.ts
  • types/CachedSource.d.ts
  • types/CompatSource.d.ts
  • types/ConcatSource.d.ts
  • types/OriginalSource.d.ts
  • types/PrefixSource.d.ts
  • types/RawSource.d.ts
  • types/ReplaceSource.d.ts
  • types/SizeOnlySource.d.ts
  • types/Source.d.ts
  • types/SourceMapSource.d.ts
  • types/helpers/createMappingsSerializer.d.ts
  • types/helpers/getFromStreamChunks.d.ts
  • types/helpers/getGeneratedSourceInfo.d.ts
  • types/helpers/getName.d.ts
  • types/helpers/getSource.d.ts
  • types/helpers/readMappings.d.ts
  • types/helpers/splitIntoLines.d.ts
  • types/helpers/splitIntoPotentialTokens.d.ts
  • types/helpers/streamAndGetSourceAndMap.d.ts
  • types/helpers/streamChunks.d.ts
  • types/helpers/streamChunksOfCombinedSourceMap.d.ts
  • types/helpers/streamChunksOfRawSource.d.ts
  • types/helpers/streamChunksOfSourceMap.d.ts
  • types/helpers/stringBufferUtils.d.ts
  • types/index.d.ts
💤 Files with no reviewable changes (10)
  • lib/ReplaceSource.js
  • lib/CompatSource.js
  • lib/RawSource.js
  • lib/OriginalSource.js
  • lib/SizeOnlySource.js
  • lib/ConcatSource.js
  • test/ReplaceSource.js
  • lib/PrefixSource.js
  • lib/SourceMapSource.js
  • lib/CachedSource.js

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.

_sourceMapAsBuffer: undefined | Buffer;
_hasOriginalSource: boolean;
_originalSourceAsString: string | undefined;
_originalSourceAsBuffer: Buffer<ArrayBufferLike> | undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🌐 Web query:

Which @types/node version made Buffer generic (Buffer<TArrayBuffer>)?

💡 Result:

<source_evidence>
<source>
<title>node: Make `Buffer` generic to align with `Uint8Array`</title>
<location>GitHub pull request 70694 in DefinitelyTyped/DefinitelyTyped (link omitted to avoid creating a cross-reference)</location>
<excerpt># node: Make `Buffer` generic to align with `Uint8Array` ... - [x] Use a meaningful title for the pull request. Include the name of the package modified. - [x] Test the change in your own code. (Compile and run.) - [x] Add or edit tests to reflect the change. - [x] Follow the advice from the readme. - [x] Avoid common mistakes. - [x] Run `pnpm test `. If updating an existing definition: - [x] Provide a URL to documentation or source code which provides context for the suggested changes: https://github.com/microsoft/TypeScript/pull/59417 - [ ] If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the `package.json`. This reintroduces `&quot;typesVersions&quot;` to the node types in what is hopefully a fairly minimal way so as to allow `Buffer` to be generic over `ArrayBufferLike` in the same way that `Uint8Array` is in TypeScript 5.7. This also removes the `WithArrayBufferLike` helper type as it is no longer necessary. ... &gt; &quot;name&quot;: &quot;node&quot;, &gt; &quot;kind&quot;: &quot;edit&quot;, ... &gt; &quot;files ... &gt; { &gt; &quot;path&quot;: &quot;types/node/buffer.buffer.d.ts&quot;, &gt; &quot;kind&quot;: &quot;definition&quot; &gt; }, ... &gt; &quot;path&quot;: &quot;types/node/buffer.d.ts&quot;, &gt; &quot;kind&quot;: &quot;definition&quot;</excerpt>
</source>
<source>
<title>972af4c Upgrade `@vscode/test-electron` 2.3.8 → 3.0.0 (with TypeScript 5.9.3) (`#1979`)</title>
<location>https://github.com/databricks/databricks-vscode/commit/972af4cda4824333bfa8f0172ceba0d641b70a75</location>
<excerpt># 972af4c Upgrade `@vscode/test-electron` 2.3.8 → 3.0.0 (with TypeScript 5.9.3) (`#1979`) - SHA: 972af4cda4824333bfa8f0172ceba0d641b70a75 - Repository: databricks/databricks-vscode - Author: rugpanov - Date: 2026-07-07T12:07:36Z - +18 -35 in 2 files - Verified: yes --- Upgrade `@vscode/test-electron` 2.3.8 → 3.0.0 (with TypeScript 5.9.3) (`#1979`) ## Why Dependabot `#1974` bumped `@vscode/test-electron` to 3.0.0 but the one-line `package.json` change **breaks the build**. test-electron 3 ships a `.d.ts` (`out/util.d.ts`) that uses the generic `Buffer ` type, which `@types/node@22` only exposes to **TypeScript &gt;= 5.7** (its `typesVersions` maps TS &lt;=5.6 to a non-generic `Buffer` variant). The repo was pinned to `typescript@^5.3.3`, so tsc reported: ``` error TS2315: Type &`#39`;Buffer&`#39`; is not generic. ``` The bump also left `yarn.lock` out of sync. Rather than mask the mismatch with a repo-wide `skipLibCheck` (which would stop type-checking **all** `.d.ts` files and could hide real dependency type errors), this fixes the **root cause** by raising TypeScript to a version that type-checks test-electron 3&`#39`;s declarations natively. ## What - Bump `@vscode/test-electron` `^2.3.8` → `^3.0.0`. - Bump `typescript` `^5.3.3` → `^5.9.3` (&gt;=5.7 for the generic `Buffer`; stays &lt;6.1.0 so `@typescript-eslint@8`&`#39`;s peer range and `ts-node@10` remain satisfied — TS 6.0 breaks both, tracked separately in `#1975`). - Regenerate `yarn.lock` (also dedupes the previously-split direct `2.3.8` / transitive `2.5.2` test-electron resolutions onto `3.0.0`). Test-only devtooling — no product/user-facing change. test-electron 3&`#39`;s only declared behavioural change over v2 is requiring Node &gt;=22, which the extension already mandates (`engines.node &gt;=22.0`) and CI runs on. ## Verification - `yarn install --immutable` passes (no `YN0028`, no `YN0060`). - `yarn run build` (`tsc --build`) succeeds with **0 errors** under TS 5.9.3 — the generic-Buffer error is resolved natively, no `skipLibCheck`. - `eslint src --ext ts` clean (typescript-eslint@8 handles TS 5.9). - `ts-mocha --type-check` of the `sdk-extensions` integ suite type-checks. - `yarn run test:unit`: **268 passing, 0 failing**. (The pre-existing `ClusterLoader` unhandled-rejection console noise is unrelated and also present on main.) Supersedes `#1974`. This pull request and its description were written by Isaac. --- _This PR was created with GitHub MCP._ ## Changed Files | File | Status | + | - | | --- | --- | --- | --- | | packages/databricks-vscode/package.json | modified | 2 | 2 | | yarn.lock | modified | 16 | 33 |</excerpt>
</source>
<source>
<title>Result 3</title>
<location>https://cdn.jsdelivr.net/npm/@types/node@22.9.0/buffer.buffer.d.ts</location>
<excerpt>/** * Produces a Buffer backed by the same allocated memory as * the given {ArrayBuffer}/{SharedArrayBuffer}. * * `@param` arrayBuffer The ArrayBuffer with which to share memory. * `@deprecated` since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead. */ new (arrayBuffer: TArrayBuffer): Buffer; /** ... * A `TypeError` will be thrown if `size` is not a number. * `@since` v5.12.0 * `@param` size The desired length of the new `Buffer`. */ allocUnsafeSlow(size: number): Buffer; } interface Buffer extends Uint8Array { // see buffer.d.ts for implementation shared with all TypeScript versions /** * Returns a new `Buffer` that references the same memory as the original, but ... * offset and cropped by the `start` and `end` indices</excerpt>
</source>
<source>
<title>Update tests and definitions to support generic typed arrays</title>
<location>GitHub pull request 70390 in DefinitelyTyped/DefinitelyTyped (link omitted to avoid creating a cross-reference)</location>
<excerpt>This updates the tests for a number of packages to be compatible with an upcoming change to TypeScript which makes typed arrays like `Uint8Array` generic over the `ArrayBuffer` or `SharedArrayBuffer` they are created with. This also introduces a backwards compatible workaround for `Buffer`, which is a subclass of `Uint8Array`, so that a `Buffer` continues to be assignable to a `Uint8Array ` in both older and newer editions of TypeScript. Please fill in this template. - [x] Use a meaningful title for the pull request. Include the name of the package modified. - [x] Test the change in your own code. (Compile and run.) - [ ] Add or edit tests to reflect the change. - [x] Follow the advice from the readme. - [x] Avoid common mistakes. - [x] Run `pnpm test `. If changing an existing definition: - [x] Provide a URL to documentation or source code which provides context for the suggested changes: https://github.com/microsoft/TypeScript/pull/59417 - [ ] ~~If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the `package.json`.~~ ... &gt; &quot;name&quot;: &quot;node&quot;, &gt; &quot;kind&quot;: &quot;edit&quot;, &gt; &quot;files&quot;: [ &gt; { &gt; &quot;path&quot;: &quot;types/node/buffer.d.ts&quot;, &gt; &quot;kind&quot;: &quot;definition&quot; &gt; }, ... &gt; { &gt; &quot;path&quot;: &quot;types/node/v16/buffer.d.ts&quot;, &gt; &quot;kind&quot;: &quot;definition&quot; &gt; }, ... &gt; { &gt; &quot;path&quot;: &quot;types/node/v18/buffer.d.ts&quot;, &gt; &quot;kind&quot;: &quot;definition&quot; &gt; }, ... &gt; { &gt; &quot;path&quot;: &quot;types/node/v20/buffer.d.ts&quot;, &gt; &quot;kind&quot;: &quot;definition&quot; &gt; }, ... - Review by Renegade334: I believe that these need to go as well before the various typed array interfaces become generic: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/d667ea73db0431a8d45829a7523f67e1d4bfdfd6/types/node/globals.d.ts#L205-L228 They were added a couple of months prior to lib.es2022.array being added to TS, in order to &quot;jump the gun&quot; on the new feature. ECMA features shouldn&`#39`;t be here anyway, so I think the simplest solution is just to get rid. This will cause new TS2550 errors for anyone using `.at()` without including lib.es2022.array, but the error text gives clear instructions on how to fix.</excerpt>
</source>
<source>
<title>types/node/buffer.buffer.d.ts at b4f65b920e76b97dc731ff8ebbcd2d6915998332 · DefinitelyTyped/DefinitelyTyped</title>
<location>https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b4f65b920e76b97dc731ff8ebbcd2d6915998332/types/node/buffer.buffer.d.ts</location>
<excerpt>&lt;ArrayBuffer ... /** * Produces a Buffer backed by the same allocated memory as * the given {ArrayBuffer}/{SharedArrayBuffer}. * * `@param` arrayBuffer The ArrayBuffer with which to share memory. * `@deprecated` since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead. */ new&lt;TArrayBuffer extends ArrayBufferLike = ArrayBuffer&gt;(arrayBuffer: TArrayBuffer): Buffer&lt;TArrayBuffer&gt;; /** * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`. * Array entries outside that range will be truncated to fit into it. * * ```js * import { Buffer } from &`#39`;node:buffer&`#39`;; * * // Creates a new Buffer containing ... from([0x ... , 0 ... * ... another type appropriate for `Buffer.from()` * variants. * * It is important to remember that a backing `ArrayBuffer` can cover a range * of memory that extends beyond the bounds of a `TypedArray` view. A new * `Buffer` created using the `buffer` property of a `TypedArray` may extend * beyond the range of the `TypedArray`: * * ```js * import { Buffer } from &`#39`;node:buffer&`#39`;; * * const arrA = Uint8Array.from([0x63, 0x64, 0x65, 0x66]); // 4 elements * const arrB = new Uint8Array(arrA.buffer, 1, 2); // 2 elements * console.log(arrA.buffer === arrB.buffer); // true * * const buf = Buffer.from(arrB.buffer); * console.log(buf); * // Prints: &lt;Buffer 63 64 65 66&gt; * ``` * `@since` v5.10.0 ... `@param` arrayBuffer An ... ArrayBuffer`, `SharedArrayBuffer`, ... example the ... byteOffset Index of first byte to ... , byteOffset?: number ... length?: number ... &lt;TArrayBuffer&gt;&gt;; /** * Creates a new `Buffer` containing `string`. The `encoding ... parameter identifies * ... character encoding to be used when converting ... string` into bytes. ... * * ```js ... * import { Buffer } from &`#39`;node:buffer&`#39`;; ... * const buf1 = Buffer.from(&`#39`;this ... Buffer.from(&`#39`; ... a small chunk ... * memory from a pool ... an indeterminate amount of time, it may be appropriate ... * to ... then copying out ... * ```js ... * import { ... * // Need to keep around a few small chunks of memory. * const store = []; * * socket.on(&`#39`;readable&`#39`;, () =&gt; { * let data; * while (null !== (data = readable.read())) { * // Allocate ... * const sb = ... .allocUnsafeSlow(10); * * // Copy the data into ... new allocation. ... * data.copy(sb, 0, 0, 10); * * store.push(sb); * } * }); * ``` * * A `TypeError` will be thrown if `size` is not a number. * `@since` v5.12.0 * `@param` size The desired length of the new `Buffer`. */ allocUnsafeSlow(size: number): Buffer&lt;ArrayBuffer&gt;; ... interface Buffer&lt;TArrayBuffer extends ... ArrayBufferLike&gt; extends Uint8Array ... TArrayBuffer&gt; ... see buffer.d.ts for implementation shared with all TypeScript versions ... // Prints: cuffer ... * console.log(buf.toString()); ... * // Also prints: cuffer (!) * ``` * ... since v0.3.0 * `@deprecated` Use `subarray` instead. * `@param` [start=0] Where the new `Buffer` will start. * `@param` [end=buf.length] Where the new `Buffer` will end (not ... */ ... slice(start ... number, end ... * Returns a new `Buffer` ... original, but * offset ... the `start` ... `end` indices. * * Specifying `end` greater than `buf.length` will return the same result as * that of `end` equal to `buf.length`. * * This method is inherited from ... TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray). * * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap. * * ```js * import { Buffer } from &`#39`;node:buffer&`#39`;; * * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte * // from the original `Buffer`. * * const buf1 = Buffer.allocUnsafe(26); * * for (let i = 0; i &lt; 26; i++) { * // 97 is the decimal ASCII value for &`#39`;a&`#39`;. * buf1[i] = i + 97; * } * * const buf2 = buf1.subarray(0, 3); * * console.log(buf2.…[truncated]</excerpt>
</source>
</source_evidence>

Citations:

- 1: GitHub pull request 70694 in DefinitelyTyped/DefinitelyTyped (link omitted to avoid creating a cross-reference)
- 2: https://github.com/databricks/databricks-vscode/commit/972af4cda4824333bfa8f0172ceba0d641b70a75
- 3: https://cdn.jsdelivr.net/npm/@types/node@22.9.0/buffer.buffer.d.ts

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- diff stat ---'
git diff --stat 6f9c00efc9df51c25030a9fd3cee4e98b9898412 4b743c9d6e59caed1a5ecf127f746feb9f151297 -- types lib package.json tsconfig.json jsconfig.json 2>/dev/null || true
printf '%s\n' '--- changed declaration context ---'
for f in types/SourceMapSource.d.ts types/CachedSource.d.ts; do
  if git cat-file -e 4b743c9d6e59caed1a5ecf127f746feb9f151297:"$f" 2>/dev/null; then
    echo "### $f"
    git show 4b743c9d6e59caed1a5ecf127f746feb9f151297:"$f" | nl -ba | sed -n '35,105p'
  fi
done
printf '%s\n' '--- source definitions and annotations ---'
for f in lib/SourceMapSource.js lib/CachedSource.js; do
  if git cat-file -e 4b743c9d6e59caed1a5ecf127f746feb9f151297:"$f" 2>/dev/null; then
    echo "### $f"
    git show 4b743c9d6e59caed1a5ecf127f746feb9f151297:"$f" | nl -ba | sed -n '1,240p'
  fi
done
printf '%s\n' '--- relevant package/config files ---'
for f in package.json tsconfig.json jsconfig.json; do
  if git cat-file -e 4b743c9d6e59caed1a5ecf127f746feb9f151297:"$f" 2>/dev/null; then
    echo "### $f"
    git show 4b743c9d6e59caed1a5ecf127f746feb9f151297:"$f" | sed -n '1,240p'
  fi
done
printf '%s\n' '--- repository references ---'
rg -n --glob '!node_modules' --glob '!dist' 'typescript|`@types/node`|skipLibCheck|declaration|SourceMapSource|CachedSource' . | head -240

Repository: webpack/webpack-sources

Length of output: 41965


🏁 Script executed:

#!/bin/bash
set -eu
HEAD=4b743c9d6e59caed1a5ecf127f746feb9f151297
BASE=6f9c00efc9df51c25030a9fd3cee4e98b9898412
printf '%s\n' '--- package metadata and tsconfig ---'
for f in package.json tsconfig.json; do
  echo "### $f"
  git show "$HEAD:$f" | nl -ba | sed -n '1,180p'
done
printf '%s\n' '--- base/head declaration existence and cited declarations ---'
for f in types/SourceMapSource.d.ts types/CachedSource.d.ts; do
  echo "### $f at base"
  git cat-file -e "$BASE:$f" 2>/dev/null && git show "$BASE:$f" | nl -ba | sed -n '1,130p' || echo absent
  echo "### $f at head"
  git show "$HEAD:$f" | nl -ba | sed -n '1,130p'
done
printf '%s\n' '--- source method ranges ---'
for spec in 'lib/SourceMapSource.js:200,330' 'lib/CachedSource.js:100,180' 'lib/CachedSource.js:250,290'; do
  f=${spec%%:*}; r=${spec##*:}
  echo "### $f:$r"
  git show "$HEAD:$f" | nl -ba | sed -n "${r}p"
done
printf '%s\n' '--- exact diff for relevant source and declarations ---'
git diff "$BASE" "$HEAD" -- lib/SourceMapSource.js lib/CachedSource.js types/SourceMapSource.d.ts types/CachedSource.d.ts | sed -n '1,320p'
printf '%s\n' '--- support/version references ---'
git grep -n -E 'engines|typescript|`@types/node`|skipLibCheck|TypeScript|types' "$HEAD" -- README.md CHANGELOG.md package.json tsconfig.json .github 2>/dev/null | head -240 || true

Repository: webpack/webpack-sources

Length of output: 32561


🏁 Script executed:

#!/bin/bash
set -eu
HEAD=4b743c9d6e59caed1a5ecf127f746feb9f151297
printf '%s\n' '--- CachedSource _cachedBuffers context ---'
git show "$HEAD:lib/CachedSource.js" | nl -ba | grep -C 8 '_cachedBuffers'
printf '%s\n' '--- all generated generic Buffer declarations in types ---'
git grep -n 'Buffer<ArrayBufferLike>' "$HEAD" -- types

Repository: webpack/webpack-sources

Length of output: 2889


Emit non-generic Buffer types for older @types/node versions.

The generated declarations expose Buffer<ArrayBufferLike> at four public members. Consumers with a non-generic Buffer declaration receive TS2315. Add explicit JSDoc types and regenerate the declarations.

Suggested fix
diff --git a/lib/SourceMapSource.js b/lib/SourceMapSource.js
--- a/lib/SourceMapSource.js
+++ b/lib/SourceMapSource.js
@@ -77,6 +77,9 @@ class SourceMapSource extends Source {
 		this._originalSourceAsString = originalSourceIsBuffer
 			? undefined
 			: originalSource;
+		/**
+		 * `@type` {Buffer | undefined}
+		 */
 		this._originalSourceAsBuffer = originalSourceIsBuffer
 			? originalSource
 			: undefined;
@@ -211,6 +214,9 @@ class SourceMapSource extends Source {
 		return this._innerSourceMapAsObject;
 	}
 
+	/**
+	 * `@returns` {Buffer | undefined}
+	 */
 	_innerSourceMapBuffer() {
 		if (this._innerSourceMapAsBuffer === undefined && this._hasInnerSourceMap) {
 			const value = Buffer.from(this._innerSourceMapString(), "utf8");
@@ -254,6 +260,9 @@ class SourceMapSource extends Source {
 		return this._sourceMapAsObject;
 	}
 
+	/**
+	 * `@returns` {Buffer}
+	 */
 	_sourceMapBuffer() {
 		if (this._sourceMapAsBuffer === undefined) {
 			const value = Buffer.from(this._sourceMapString(), "utf8");
diff --git a/lib/CachedSource.js b/lib/CachedSource.js
--- a/lib/CachedSource.js
+++ b/lib/CachedSource.js
@@ -131,6 +131,10 @@ class CachedSource extends Source {
 		 */
 		this._cachedSource = undefined;
+		/**
+		 * `@type` {Buffer[] | undefined}
+		 */
+		this._cachedBuffers = undefined;
 		// Split on `cachedData` once instead of re-evaluating the ternary for
📍 Affects 2 files
  • types/SourceMapSource.d.ts#L54-L54 (this comment)
  • types/SourceMapSource.d.ts#L87-L87
  • types/SourceMapSource.d.ts#L93-L93
  • types/CachedSource.d.ts#L62-L62

@alexander-akait
alexander-akait merged commit fba8312 into main Sep 25, 2026
35 of 37 checks passed
@alexander-akait
alexander-akait deleted the claude/update-deps-github-actions-5ydose branch September 25, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants