From 1c29eb22a2c85175a986540836472162de3c2b21 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Tue, 16 Jan 2024 12:55:51 +0200 Subject: [PATCH] add typescript types --- .gitignore | 1 + lib/hub-observer.js | 1 + lib/plugin-hub-client.js | 2 +- package.json | 12 +++++++++--- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4b96477..873998e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ pnpm-lock.yaml package-lock.json coverage *~ +lib/*.d.ts # For misc scripts and experiments: /gitignored diff --git a/lib/hub-observer.js b/lib/hub-observer.js index b3ecac3..611d31f 100644 --- a/lib/hub-observer.js +++ b/lib/hub-observer.js @@ -174,6 +174,7 @@ module.exports = class HubObserver { /** * @param {string} pubkey + * @returns {`/${string}`} */ #getMultiaddr(pubkey) { return `/tunnel/${this.#hubPubkey}.${pubkey}/shse/${pubkey}` diff --git a/lib/plugin-hub-client.js b/lib/plugin-hub-client.js index 51b6c82..44d2584 100644 --- a/lib/plugin-hub-client.js +++ b/lib/plugin-hub-client.js @@ -3,7 +3,7 @@ const DuplexPair = require('pull-pair/duplex') // @ts-ignore const Notify = require('pull-notify') const debug = require('debug')('ppppp:hub-client') const makeTunnelPlugin = require('./ms-tunnel') -const { ErrorDuplex, msaddrToMultiaddr, multiaddrToMsaddr } = require('./utils') +const { ErrorDuplex } = require('./utils') const HUBS_SUBDOMAIN = 'hubs' diff --git a/package.json b/package.json index e101d7d..e3a7ff3 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,13 @@ "type": "git", "url": "git@github.com:staltz/ppppp-hub-client.git" }, - "main": "index.js", + "main": "lib/index.js", "files": [ - "lib/**/*.js" + "*.js", + "lib/*.js", + "lib/*.d.ts" ], + "types": "types/index.d.ts", "exports": { ".": { "require": "./lib/index.js" @@ -46,7 +49,10 @@ "typescript": "^5.1.3" }, "scripts": { - "test": "node --test", + "clean-check": "tsc --build --clean", + "prepublishOnly": "npm run clean-check && tsc --build", + "postpublish": "npm run clean-check", + "test": "npm run clean-check && node --test", "format-code": "prettier --write \"(lib|test)/**/*.js\"", "format-code-staged": "pretty-quick --staged --pattern \"(lib|test)/**/*.js\"", "coverage": "c8 --reporter=lcov npm run test"