Skip to content

chore: add TypeScript declarations (.d.ts) for public API - #273

Open
lucas-tortora wants to merge 1 commit into
holepunchto:mainfrom
lucas-tortora:chore/add-js-doc
Open

chore: add TypeScript declarations (.d.ts) for public API#273
lucas-tortora wants to merge 1 commit into
holepunchto:mainfrom
lucas-tortora:chore/add-js-doc

Conversation

@lucas-tortora

@lucas-tortora lucas-tortora commented Jul 1, 2026

Copy link
Copy Markdown

Adds a standalone index.d.ts declaring the public API — typed signatures, JSDoc-style @param/@returns doc comments, and interfaces for option shapes — instead of inline source JSDoc. Wires types/files in package.json so the declarations publish. This powers generated reference docs in the Pear docs site — keeping docs in sync with source.

Companion docs-site PR: holepunchto/pear-docs#315 (merged)

Comment thread index.js Outdated
* Options for `node.connect()`.
* @typedef {Object} ConnectOptions
* @property {Array<{host: string, port: number}>} [nodes] - Known DHT nodes close to the remote — speeds up connecting.
* @property {Array<{host: string, port: number}>} [relayAddresses] - Relay server addresses to hole-punch through when a direct connection cannot be established.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

relay addresses are not this, its an internal option to where you can tell the connect which dht nodes the other guy is likely using to relay the handshake the him (if you know)

Comment thread index.js Outdated
* topic.
* @param {Buffer} target - 32-byte topic buffer to announce under.
* @param {{publicKey: Buffer, secretKey: Buffer}} keyPair - The Ed25519 key pair to announce with.
* @param {Array<{host: string, port: number}>} [relayAddresses] - Up to 3 DHT relay node addresses to include in the announcement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

must be dht relay addresses you use yourself (when making a server), otherwise your connectivity will fail

Adds a standalone TypeScript declaration file for the public API, wires it up
via package.json "types", and ships it in the published "files". Keeping the
types in a separate .d.ts (no inline JSDoc) avoids source-file merge conflicts
while giving consumers IDE/tsc support.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lucas-tortora lucas-tortora changed the title chore: add JSDoc to public API chore: add TypeScript declarations (.d.ts) for public API Aug 5, 2026
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