diff --git a/packages/pointers/CHANGELOG.md b/packages/pointers/CHANGELOG.md index bd250af62f..f741117115 100644 --- a/packages/pointers/CHANGELOG.md +++ b/packages/pointers/CHANGELOG.md @@ -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 diff --git a/packages/pointers/src/data.ts b/packages/pointers/src/data.ts index 6dbe5229af..196054a181 100644 --- a/packages/pointers/src/data.ts +++ b/packages/pointers/src/data.ts @@ -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 @@ -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); }