Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/pointers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ itself are tracked in the root [`CHANGELOG.md`](../../CHANGELOG.md).

## Unreleased

### Fixed

- The published type declarations no longer reference Node's `util` types.
`Data.inspect` and its `util.inspect.custom` hook used
`util.InspectOptionsStylized`, which newer `@types/node` versions no longer
export, so consumers that type-checked with `skipLibCheck: false` got errors.
The options parameter is now a small local interface.

## 0.1.0-preview.2 — 2026-10-07

### Changed
Expand Down
24 changes: 16 additions & 8 deletions packages/pointers/src/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import { toHex } from "ethereum-cryptography/utils";

import type * as Util from "util";
/**
* The part of Node's `util.inspect` options that `Data` uses. Declared here so
* the published types do not depend on `@types/node`.
*/
export interface InspectOptions {
stylize(text: string, styleType: string): string;
depth?: number | null;
}

/**
* Structural stand-in for Node's `util.inspect` function.
*/
export type Inspect = (value: unknown, ...rest: unknown[]) => string;

// Symbol for custom inspect (Node.js util.inspect.custom)
// We use a well-known symbol value to avoid top-level await issues
Expand Down Expand Up @@ -100,18 +112,14 @@ export class Data extends Uint8Array {
return Data.fromHex(concatenatedHex);
}

inspect(
_depth: number,
options: Util.InspectOptionsStylized,
_inspect: typeof Util.inspect,
): string {
inspect(_depth: number, options: InspectOptions, _inspect: Inspect): string {
return `Data[${options.stylize(this.toHex(), "number")}]`;
}

[customInspectSymbol](
depth: number,
options: Util.InspectOptionsStylized,
inspect: typeof Util.inspect,
options: InspectOptions,
inspect: Inspect,
): string {
return this.inspect(depth, options, inspect);
}
Expand Down
Loading