diff --git a/examples/types-use-ipfs-from-ts/README.md b/examples/types-use-ipfs-from-ts/README.md new file mode 100644 index 0000000000..17983cdaae --- /dev/null +++ b/examples/types-use-ipfs-from-ts/README.md @@ -0,0 +1,56 @@ +# Using IPFS with Typescript + +> This example provides a template for using js-ipfs in typescript project. + + +## Before you start + +First clone this repo, install dependencies in the project root. + +``` +git clone https://github.com/ipfs/js-ipfs.git +cd js-ipfs/examples/types-use-ipfs-from-ts +npm install +``` + +You can type check this example by runing following in the example directory: + +``` +npm test +``` + +You should see following output: + +``` +> tsc --noEmit +``` + +If you remove `// @ts-expect-error` comment is `src/main.ts` on line 16 and run `npm test` once again you should see a following output instead: + +``` +tsc --noEmit + +src/main.ts:16:14 - error TS2339: Property 'toUpperCase' does not exist on type 'CID'. + +16 file.cid.toUpperCase() + ~~~~~~~~~~~ + + +Found 1 error. +``` + + +## IntelliSense + +In [VSCode](https://code.visualstudio.com/) and other code editors that provide [comparable IntelliSense features](https://docs.microsoft.com/en-us/visualstudio/ide/using-intellisense?view=vs-2019) you should be able to get code auto complete, parameter and return value information for `js-ipfs` APIs. + +![Preview](./preview.png) + +## Limitations + +- Things should work out of the box, with most `tsconfig` settings, however unless +[`skipLibCheck`](https://www.typescriptlang.org/tsconfig#skipLibCheck) is set to `true` many errors will be reported. + > That is because +types are generated from source JSDoc comments and typescript seems to emit declarations which it then complains about. + +- Not all APIs are fully entyped so you might observe gaps and `any` types here and there. We hope to improve this over time. diff --git a/examples/types-use-ipfs-from-ts/package.json b/examples/types-use-ipfs-from-ts/package.json new file mode 100644 index 0000000000..b4de6afb6a --- /dev/null +++ b/examples/types-use-ipfs-from-ts/package.json @@ -0,0 +1,13 @@ +{ + "name": "types-use-ipfs-from-ts", + "private": true, + "dependencies": { + "ipfs": "^0.51.0" + }, + "devDependencies": { + "typescript": "^4.0.3" + }, + "scripts": { + "test": "tsc --noEmit" + } +} diff --git a/examples/types-use-ipfs-from-ts/preview.png b/examples/types-use-ipfs-from-ts/preview.png new file mode 100644 index 0000000000..07edb508de Binary files /dev/null and b/examples/types-use-ipfs-from-ts/preview.png differ diff --git a/examples/types-use-ipfs-from-ts/src/main.ts b/examples/types-use-ipfs-from-ts/src/main.ts new file mode 100644 index 0000000000..c066d324df --- /dev/null +++ b/examples/types-use-ipfs-from-ts/src/main.ts @@ -0,0 +1,28 @@ +import IPFS from 'ipfs' + +export default async function main () { + const node = await IPFS.create() + const version = await node.version() + + console.log('Version:', version.version) + + const file = await node.add({ + path: 'hello.txt', + content: new TextEncoder().encode('Hello World 101') + }) + + console.log('Added file:', file.path, file.cid.toString()) + try { + file.cid.toUpperCase() + } catch(error) { + + } + + const decoder = new TextDecoder() + let content = '' + for await (const chunk of node.cat(file.cid)) { + content += decoder.decode(chunk) + } + + console.log('Added file contents:', content) +} diff --git a/examples/types-use-ipfs-from-ts/tsconfig.json b/examples/types-use-ipfs-from-ts/tsconfig.json new file mode 100644 index 0000000000..df5cdf36ae --- /dev/null +++ b/examples/types-use-ipfs-from-ts/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "strict": true, + "skipLibCheck": true, + "noImplicitAny": false, + "esModuleInterop": true, + "moduleResolution": "Node", + "noEmit": true + }, + "include": [ + "src" + ] +} diff --git a/examples/types-use-ipfs-from-typed-js/README.md b/examples/types-use-ipfs-from-typed-js/README.md new file mode 100644 index 0000000000..b6cc0d084c --- /dev/null +++ b/examples/types-use-ipfs-from-typed-js/README.md @@ -0,0 +1,59 @@ +# Using IPFS with typed JS + +> This example provides a template for setting up a [JS project that utilizes type checker](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html) and `js-ipfs` type [declarations the were generated from JSDoc comments](https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html) + +Things should work out of the box, only requirement is to disable +[`skipLibCheck`](https://www.typescriptlang.org/tsconfig#skipLibCheck) because type declarations generated by typescript for commonjs modules raise some issues when consumed. + + +## Before you start + +First clone this repo, install dependencies in the project root. + +``` +git clone https://github.com/ipfs/js-ipfs.git +cd js-ipfs/examples/types-use-ipfs-from-typed-js +npm install +``` + +## Type checking + +You can type check this example by runing following in the example directory: + +``` +npm test +``` + +You should see following output: + +``` +> tsc --noEmit +``` + +If you remove `// @ts-expect-error` comment is `src/main.js` on line 16 and run `npm test` once again you should see a following output instead: + +``` +> tsc --noEmit +src/main.js:16:14 - error TS2339: Property 'toUpperCase' does not exist on type 'CID'. + +16 file.cid.toUpperCase() + ~~~~~~~~~~~ + + +Found 1 error. +``` + +## IntelliSense + +In [VSCode](https://code.visualstudio.com/) and other code editors that provide [comparable IntelliSense features](https://docs.microsoft.com/en-us/visualstudio/ide/using-intellisense?view=vs-2019) you should be able to get code auto complete, parameter and return value information for `js-ipfs` APIs. + +![Preview](./preview.png) + +## Limitations + +- Things should work out of the box, with most `tsconfig` settings, however unless +[`skipLibCheck`](https://www.typescriptlang.org/tsconfig#skipLibCheck) is set to `true` many errors will be reported. + > That is because +types are generated from source JSDoc comments and typescript seems to emit declarations which it then complains about. + +- Not all APIs are fully entyped so you might observe gaps and `any` types here and there. We hope to improve this over time. diff --git a/examples/types-use-ipfs-from-typed-js/package.json b/examples/types-use-ipfs-from-typed-js/package.json new file mode 100644 index 0000000000..95724a6527 --- /dev/null +++ b/examples/types-use-ipfs-from-typed-js/package.json @@ -0,0 +1,13 @@ +{ + "name": "types-use-ipfs-from-typed-js", + "private": true, + "dependencies": { + "ipfs": "^0.51.0" + }, + "devDependencies": { + "typescript": "^4.0.3" + }, + "scripts": { + "test": "tsc --noEmit" + } +} diff --git a/examples/types-use-ipfs-from-typed-js/preview.png b/examples/types-use-ipfs-from-typed-js/preview.png new file mode 100644 index 0000000000..ab897d0f57 Binary files /dev/null and b/examples/types-use-ipfs-from-typed-js/preview.png differ diff --git a/examples/types-use-ipfs-from-typed-js/src/main.js b/examples/types-use-ipfs-from-typed-js/src/main.js new file mode 100644 index 0000000000..79af577bcb --- /dev/null +++ b/examples/types-use-ipfs-from-typed-js/src/main.js @@ -0,0 +1,30 @@ +const IPFS = require('ipfs') + +async function main () { + const node = await IPFS.create() + const version = await node.version() + + console.log('Version:', version.version) + + const file = await node.add({ + path: 'hello.txt', + content: new TextEncoder().encode('Hello World 101') + }) + + console.log('Added file:', file.path, file.cid.toString()) + try { + file.cid.toUpperCase() + } catch(error) { + + } + + const decoder = new TextDecoder() + let content = '' + for await (const chunk of node.cat(file.cid)) { + content += decoder.decode(chunk) + } + + console.log('Added file contents:', content) +} + +main() diff --git a/examples/types-use-ipfs-from-typed-js/tsconfig.json b/examples/types-use-ipfs-from-typed-js/tsconfig.json new file mode 100644 index 0000000000..e3bbece785 --- /dev/null +++ b/examples/types-use-ipfs-from-typed-js/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "strict": true, + "skipLibCheck": true, + "noImplicitAny": false, + "esModuleInterop": true, + "moduleResolution": "Node", + "noEmit": true + }, + "include": [ + "src" + ] +} diff --git a/packages/ipfs-core-utils/package.json b/packages/ipfs-core-utils/package.json index d37b28e7cc..e55a935137 100644 --- a/packages/ipfs-core-utils/package.json +++ b/packages/ipfs-core-utils/package.json @@ -14,7 +14,8 @@ "typesVersions": { "*": { "*": [ - "dist/*" + "dist/*", + "dist/*/index" ] } }, diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index b35233c8ea..2aa45da51b 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -28,7 +28,8 @@ "typesVersions": { "*": { "*": [ - "dist/*" + "dist/*", + "dist/*/index" ] } }, diff --git a/packages/ipfs-core/src/components/files/index.js b/packages/ipfs-core/src/components/files/index.js index e5f29180de..0ee1e50b2f 100644 --- a/packages/ipfs-core/src/components/files/index.js +++ b/packages/ipfs-core/src/components/files/index.js @@ -5,17 +5,17 @@ const isIpfs = require('is-ipfs') /** * @typedef {Object} MFS - * @property {ReturnType} stat - * @property {ReturnType} chmod - * @property {ReturnType} cp - * @property {ReturnType} flush - * @property {ReturnType} mkdir - * @property {ReturnType} mv - * @property {ReturnType} rm - * @property {ReturnType} touch - * @property {ReturnType} write - * @property {ReturnType} read - * @property {ReturnType} ls + * @property {ReturnType} stat + * @property {ReturnType} chmod + * @property {ReturnType} cp + * @property {ReturnType} flush + * @property {ReturnType} mkdir + * @property {ReturnType} mv + * @property {ReturnType} rm + * @property {ReturnType} touch + * @property {ReturnType} write + * @property {ReturnType} read + * @property {ReturnType} ls */ // These operations are read-locked at the function level and will execute simultaneously diff --git a/packages/ipfs-core/src/components/index.js b/packages/ipfs-core/src/components/index.js index fd4f8c1794..cc68c7cb2e 100644 --- a/packages/ipfs-core/src/components/index.js +++ b/packages/ipfs-core/src/components/index.js @@ -1,22 +1,22 @@ 'use strict' /** - * @typedef {ReturnType} Add + * @typedef {ReturnType} Add */ exports.add = require('./add') /** - * @typedef {ReturnType} AddAll + * @typedef {ReturnType} AddAll */ exports.addAll = require('./add-all') /** * @typedef {Object} Block - * @property {ReturnType} get - * @property {ReturnType} put - * @property {ReturnType} rm - * @property {ReturnType} stat + * @property {ReturnType} get + * @property {ReturnType} put + * @property {ReturnType} rm + * @property {ReturnType} stat */ exports.block = { get: require('./block/get'), @@ -27,9 +27,9 @@ exports.block = { /** * @typedef {Object} BitSwap - * @property {ReturnType} stat - * @property {ReturnType} unwant - * @property {ReturnType} wantlist + * @property {ReturnType} stat + * @property {ReturnType} unwant + * @property {ReturnType} wantlist */ exports.bitswap = { stat: require('./bitswap/stat'), @@ -40,9 +40,9 @@ exports.bitswap = { /** * @typedef {Object} Bootstrap - * @property {ReturnType} add - * @property {ReturnType} list - * @property {ReturnType} rm + * @property {ReturnType} add + * @property {ReturnType} list + * @property {ReturnType} rm */ exports.bootstrap = { add: require('./bootstrap/add'), @@ -53,21 +53,21 @@ exports.bootstrap = { } /** - * @typedef {ReturnType} Cat + * @typedef {ReturnType} Cat */ exports.cat = require('./cat') /** - * @typedef {ReturnType} Config + * @typedef {ReturnType} Config */ exports.config = require('./config') /** * @typedef {Object} DAG - * @property {ReturnType} get - * @property {ReturnType} put - * @property {ReturnType} resolve - * @property {ReturnType} tree + * @property {ReturnType} get + * @property {ReturnType} put + * @property {ReturnType} resolve + * @property {ReturnType} tree */ exports.dag = { get: require('./dag/get'), @@ -76,36 +76,36 @@ exports.dag = { tree: require('./dag/tree') } -/** @typedef {ReturnType} DHT */ +/** @typedef {ReturnType} DHT */ exports.dht = require('./dht') -/** @typedef {ReturnType} DNS */ +/** @typedef {ReturnType} DNS */ exports.dns = require('./dns') -/** @typedef {ReturnType} Files */ +/** @typedef {ReturnType} Files */ exports.files = require('./files') -/** @typedef {ReturnType} Get */ +/** @typedef {ReturnType} Get */ exports.get = require('./get') -/** @typedef {ReturnType} ID */ +/** @typedef {ReturnType} ID */ exports.id = require('./id') -/** @typedef {ReturnType} Init */ +/** @typedef {ReturnType} Init */ exports.init = require('./init') -/** @typedef {ReturnType} IsOnline */ +/** @typedef {ReturnType} IsOnline */ exports.isOnline = require('./is-online') /** * @typedef {Object} Key - * @property {ReturnType} export - * @property {ReturnType} gen - * @property {ReturnType} import - * @property {ReturnType} info - * @property {ReturnType} list - * @property {ReturnType} rename - * @property {ReturnType} rm + * @property {ReturnType} export + * @property {ReturnType} gen + * @property {ReturnType} import + * @property {ReturnType} info + * @property {ReturnType} list + * @property {ReturnType} rename + * @property {ReturnType} rm */ exports.key = { @@ -118,22 +118,22 @@ exports.key = { rm: require('./key/rm') } -/** @typedef {ReturnType} LibP2P */ +/** @typedef {ReturnType} LibP2P */ exports.libp2p = require('./libp2p') -/** @typedef {ReturnType} LS */ +/** @typedef {ReturnType} LS */ exports.ls = require('./ls') /** * @typedef {Object} Name - * @property {ReturnType} publish - * @property {ReturnType} resolve + * @property {ReturnType} publish + * @property {ReturnType} resolve * @property {NamePubSub} pubsub * * @typedef {Object} NamePubSub - * @property {ReturnType} cancel - * @property {ReturnType} state - * @property {ReturnType} subs + * @property {ReturnType} cancel + * @property {ReturnType} state + * @property {ReturnType} subs */ exports.name = { @@ -148,19 +148,19 @@ exports.name = { /** * @typedef {Object} ObjectAPI - * @property {ReturnType} data - * @property {ReturnType} get - * @property {ReturnType} links - * @property {ReturnType} new - * @property {ReturnType} put - * @property {ReturnType} stat + * @property {ReturnType} data + * @property {ReturnType} get + * @property {ReturnType} links + * @property {ReturnType} new + * @property {ReturnType} put + * @property {ReturnType} stat * @property {ObjectPath} patch * * @typedef {Object} ObjectPath - * @property {ReturnType} addLink - * @property {ReturnType} rmLink - * @property {ReturnType} appendData - * @property {ReturnType} setData + * @property {ReturnType} addLink + * @property {ReturnType} rmLink + * @property {ReturnType} appendData + * @property {ReturnType} setData */ exports.object = { data: require('./object/data'), @@ -179,10 +179,10 @@ exports.object = { /** * @typedef Pin - * @property {ReturnType} add - * @property {ReturnType} addAll - * @property {ReturnType} ls - * @property {ReturnType} rm + * @property {ReturnType} add + * @property {ReturnType} addAll + * @property {ReturnType} ls + * @property {ReturnType} rm */ exports.pin = { add: require('./pin/add'), @@ -193,27 +193,27 @@ exports.pin = { } /** - * @typedef {ReturnType} Ping + * @typedef {ReturnType} Ping */ exports.ping = require('./ping') /** - * @typedef {ReturnType} PubSub + * @typedef {ReturnType} PubSub */ exports.pubsub = require('./pubsub') /** - * @typedef {ReturnType} Refs - * @typedef {ReturnType} LocalRefs + * @typedef {ReturnType} Refs + * @typedef {ReturnType} LocalRefs * @typedef {Refs & {local:LocalRefs}} RefsWithLocal */ exports.refs = Object.assign(require('./refs'), { local: require('./refs/local') }) /** * @typedef {Object} Repo - * @property {ReturnType} gc - * @property {ReturnType} stat - * @property {ReturnType} version + * @property {ReturnType} gc + * @property {ReturnType} stat + * @property {ReturnType} version */ exports.repo = { gc: require('./repo/gc'), @@ -221,30 +221,30 @@ exports.repo = { version: require('./repo/version') } -/** @typedef {ReturnType} Resolve */ +/** @typedef {ReturnType} Resolve */ exports.resolve = require('./resolve') -/** @typedef {ReturnType} Start */ +/** @typedef {ReturnType} Start */ exports.start = require('./start') /** * @typedef {Object} Stats - * @property {ReturnType} bw + * @property {ReturnType} bw */ exports.stats = { bw: require('./stats/bw') } -/** @typedef {ReturnType} Stop */ +/** @typedef {ReturnType} Stop */ exports.stop = require('./stop') /** * @typedef {Object} Swarm - * @property {ReturnType} addrs - * @property {ReturnType} connect - * @property {ReturnType} disconnect - * @property {ReturnType} localAddrs - * @property {ReturnType} peers + * @property {ReturnType} addrs + * @property {ReturnType} connect + * @property {ReturnType} disconnect + * @property {ReturnType} localAddrs + * @property {ReturnType} peers */ exports.swarm = { addrs: require('./swarm/addrs'), @@ -255,12 +255,12 @@ exports.swarm = { } /** - * @typedef {ReturnType} Version + * @typedef {ReturnType} Version */ exports.version = require('./version') /** - * @typedef {ReturnType} Preload + * @typedef {ReturnType} Preload * @typedef {RWLock} GCLock * * @typedef {Object} RWLock diff --git a/packages/ipfs-core/src/components/pin/add.js b/packages/ipfs-core/src/components/pin/add.js index a51e9d3807..8d10ea31f4 100644 --- a/packages/ipfs-core/src/components/pin/add.js +++ b/packages/ipfs-core/src/components/pin/add.js @@ -4,7 +4,7 @@ const last = require('it-last') /** * @param {Object} config - * @param {ReturnType} config.addAll + * @param {ReturnType} config.addAll */ module.exports = ({ addAll }) => /** diff --git a/packages/ipfs-core/src/components/pin/rm.js b/packages/ipfs-core/src/components/pin/rm.js index 92bd4a8961..dbb9c47317 100644 --- a/packages/ipfs-core/src/components/pin/rm.js +++ b/packages/ipfs-core/src/components/pin/rm.js @@ -4,7 +4,7 @@ const last = require('it-last') /** * @param {Object} config - * @param {ReturnType} config.rmAll + * @param {ReturnType} config.rmAll */ module.exports = ({ rmAll }) => /** diff --git a/packages/ipfs-http-client/package.json b/packages/ipfs-http-client/package.json index 6daf57d365..9530fc577e 100644 --- a/packages/ipfs-http-client/package.json +++ b/packages/ipfs-http-client/package.json @@ -23,7 +23,8 @@ "typesVersions": { "*": { "*": [ - "dist/*" + "dist/*", + "dist/*/index" ] } }, diff --git a/packages/ipfs-http-client/src/add-all.js b/packages/ipfs-http-client/src/add-all.js index 1a97a3db74..ba226c8570 100644 --- a/packages/ipfs-http-client/src/add-all.js +++ b/packages/ipfs-http-client/src/add-all.js @@ -10,7 +10,7 @@ const AbortController = require('native-abort-controller') module.exports = configure((api) => { /** - * @type {import('.').Implements} + * @type {import('.').Implements} */ async function * addAll (source, options = {}) { const progressFn = options.progress diff --git a/packages/ipfs-http-client/src/add.js b/packages/ipfs-http-client/src/add.js index 0cdd83eaae..83383db4fa 100644 --- a/packages/ipfs-http-client/src/add.js +++ b/packages/ipfs-http-client/src/add.js @@ -11,7 +11,7 @@ module.exports = (options) => { const all = addAll(options) return configure(() => { /** - * @type {import('.').Implements} + * @type {import('.').Implements} */ async function add (input, options = {}) { // @ts-ignore - last may return undefind if source is empty diff --git a/packages/ipfs-http-client/src/bitswap/unwant.js b/packages/ipfs-http-client/src/bitswap/unwant.js index 806827acf9..60c9e144d4 100644 --- a/packages/ipfs-http-client/src/bitswap/unwant.js +++ b/packages/ipfs-http-client/src/bitswap/unwant.js @@ -6,7 +6,7 @@ const toUrlSearchParams = require('../lib/to-url-search-params') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ async function unwant (cid, options = {}) { const res = await api.post('bitswap/unwant', { diff --git a/packages/ipfs-http-client/src/block/get.js b/packages/ipfs-http-client/src/block/get.js index ea29369b38..84377477d6 100644 --- a/packages/ipfs-http-client/src/block/get.js +++ b/packages/ipfs-http-client/src/block/get.js @@ -7,7 +7,7 @@ const toUrlSearchParams = require('../lib/to-url-search-params') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ async function get (cid, options = {}) { // @ts-ignore - CID|string seems to confuse typedef diff --git a/packages/ipfs-http-client/src/block/put.js b/packages/ipfs-http-client/src/block/put.js index d64b747ff9..669ea710d0 100644 --- a/packages/ipfs-http-client/src/block/put.js +++ b/packages/ipfs-http-client/src/block/put.js @@ -11,7 +11,7 @@ const AbortController = require('native-abort-controller') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ async function put (data, options = {}) { if (Block.isBlock(data)) { diff --git a/packages/ipfs-http-client/src/block/rm.js b/packages/ipfs-http-client/src/block/rm.js index 66930c9458..6137194d9a 100644 --- a/packages/ipfs-http-client/src/block/rm.js +++ b/packages/ipfs-http-client/src/block/rm.js @@ -6,7 +6,7 @@ const toUrlSearchParams = require('../lib/to-url-search-params') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ async function * rm (cid, options = {}) { if (!Array.isArray(cid)) { diff --git a/packages/ipfs-http-client/src/block/stat.js b/packages/ipfs-http-client/src/block/stat.js index 8ca0cd8349..94f37be7c8 100644 --- a/packages/ipfs-http-client/src/block/stat.js +++ b/packages/ipfs-http-client/src/block/stat.js @@ -6,7 +6,7 @@ const toUrlSearchParams = require('../lib/to-url-search-params') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ async function stat (cid, options = {}) { const res = await api.post('block/stat', { diff --git a/packages/ipfs-http-client/src/bootstrap/add.js b/packages/ipfs-http-client/src/bootstrap/add.js index c2efcab28c..781354b9ea 100644 --- a/packages/ipfs-http-client/src/bootstrap/add.js +++ b/packages/ipfs-http-client/src/bootstrap/add.js @@ -6,7 +6,7 @@ const Multiaddr = require('multiaddr') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ async function add (addr, options = {}) { const res = await api.post('bootstrap/add', { diff --git a/packages/ipfs-http-client/src/bootstrap/clear.js b/packages/ipfs-http-client/src/bootstrap/clear.js index 6a334847eb..5b437bd53f 100644 --- a/packages/ipfs-http-client/src/bootstrap/clear.js +++ b/packages/ipfs-http-client/src/bootstrap/clear.js @@ -6,7 +6,7 @@ const Multiaddr = require('multiaddr') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ async function clear (options = {}) { const res = await api.post('bootstrap/rm', { diff --git a/packages/ipfs-http-client/src/bootstrap/list.js b/packages/ipfs-http-client/src/bootstrap/list.js index 515cc2daf4..f15ac71160 100644 --- a/packages/ipfs-http-client/src/bootstrap/list.js +++ b/packages/ipfs-http-client/src/bootstrap/list.js @@ -6,7 +6,7 @@ const Multiaddr = require('multiaddr') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ async function list (options = {}) { const res = await api.post('bootstrap/list', { diff --git a/packages/ipfs-http-client/src/bootstrap/reset.js b/packages/ipfs-http-client/src/bootstrap/reset.js index f037076d68..5eb9e5c3fd 100644 --- a/packages/ipfs-http-client/src/bootstrap/reset.js +++ b/packages/ipfs-http-client/src/bootstrap/reset.js @@ -6,7 +6,7 @@ const Multiaddr = require('multiaddr') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ async function reset (options = {}) { const res = await api.post('bootstrap/add', { diff --git a/packages/ipfs-http-client/src/bootstrap/rm.js b/packages/ipfs-http-client/src/bootstrap/rm.js index 89c4506d01..9eab1100ce 100644 --- a/packages/ipfs-http-client/src/bootstrap/rm.js +++ b/packages/ipfs-http-client/src/bootstrap/rm.js @@ -6,7 +6,7 @@ const Multiaddr = require('multiaddr') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ async function rm (addr, options = {}) { const res = await api.post('bootstrap/rm', { diff --git a/packages/ipfs-http-client/src/cat.js b/packages/ipfs-http-client/src/cat.js index d1f3b81cf0..7719a06ee9 100644 --- a/packages/ipfs-http-client/src/cat.js +++ b/packages/ipfs-http-client/src/cat.js @@ -6,7 +6,7 @@ const toUrlSearchParams = require('./lib/to-url-search-params') module.exports = configure(api => { /** - * @type {import('.').Implements} + * @type {import('.').Implements} */ async function * cat (path, options = {}) { const res = await api.post('cat', { diff --git a/packages/ipfs-http-client/src/dag/get.js b/packages/ipfs-http-client/src/dag/get.js index e63f058e6b..0d03d31308 100644 --- a/packages/ipfs-http-client/src/dag/get.js +++ b/packages/ipfs-http-client/src/dag/get.js @@ -10,7 +10,7 @@ module.exports = configure((api, opts) => { const load = loadFormat(opts.ipld) /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ const get = async (cid, options = {}) => { const resolved = await dagResolve(cid, options) diff --git a/packages/ipfs-http-client/src/dag/put.js b/packages/ipfs-http-client/src/dag/put.js index 2a22176591..b1d0e8ae01 100644 --- a/packages/ipfs-http-client/src/dag/put.js +++ b/packages/ipfs-http-client/src/dag/put.js @@ -14,7 +14,7 @@ module.exports = configure((api, opts) => { const load = loadFormat(opts.ipld) /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ const put = async (dagNode, options = {}) => { if (options.cid && (options.format || options.hashAlg)) { diff --git a/packages/ipfs-http-client/src/dag/resolve.js b/packages/ipfs-http-client/src/dag/resolve.js index b0e2a56ce1..18a294d323 100644 --- a/packages/ipfs-http-client/src/dag/resolve.js +++ b/packages/ipfs-http-client/src/dag/resolve.js @@ -6,7 +6,7 @@ const toUrlSearchParams = require('../lib/to-url-search-params') module.exports = configure(api => { /** - * @type {import('..').Implements} + * @type {import('..').Implements} */ const resolve = async (ipfsPath, options = {}) => { const res = await api.post('dag/resolve', { diff --git a/packages/ipfs-http-client/src/dns.js b/packages/ipfs-http-client/src/dns.js index 2786cc42ee..42d90f44d0 100644 --- a/packages/ipfs-http-client/src/dns.js +++ b/packages/ipfs-http-client/src/dns.js @@ -5,7 +5,7 @@ const toUrlSearchParams = require('./lib/to-url-search-params') module.exports = configure(api => { /** - * @type {import('.').Implements} + * @type {import('.').Implements} */ const dns = async (domain, options = {}) => { const res = await api.post('dns', { diff --git a/packages/ipfs-http-client/src/get.js b/packages/ipfs-http-client/src/get.js index 8ceaa14863..b0ed304d4a 100644 --- a/packages/ipfs-http-client/src/get.js +++ b/packages/ipfs-http-client/src/get.js @@ -8,7 +8,7 @@ const map = require('it-map') module.exports = configure(api => { /** - * @type {import('.').Implements} + * @type {import('.').Implements} */ async function * get (path, options = {}) { const res = await api.post('get', { diff --git a/packages/ipfs-http-client/src/id.js b/packages/ipfs-http-client/src/id.js index 89d1d95641..28b2e3ff98 100644 --- a/packages/ipfs-http-client/src/id.js +++ b/packages/ipfs-http-client/src/id.js @@ -7,7 +7,7 @@ const toUrlSearchParams = require('./lib/to-url-search-params') module.exports = configure(api => { /** - * @type {import('.').Implements} + * @type {import('.').Implements} */ async function id (options = {}) { const res = await api.post('id', { diff --git a/packages/ipfs-http-client/src/resolve.js b/packages/ipfs-http-client/src/resolve.js index a8dbfa608e..0438013ea8 100644 --- a/packages/ipfs-http-client/src/resolve.js +++ b/packages/ipfs-http-client/src/resolve.js @@ -5,7 +5,7 @@ const toUrlSearchParams = require('./lib/to-url-search-params') module.exports = configure(api => { /** - * @type {import('.').Implements} + * @type {import('.').Implements} */ async function resolve (path, options = {}) { const res = await api.post('resolve', { diff --git a/packages/ipfs-http-client/src/version.js b/packages/ipfs-http-client/src/version.js index c2cc538e36..368e709533 100644 --- a/packages/ipfs-http-client/src/version.js +++ b/packages/ipfs-http-client/src/version.js @@ -7,7 +7,7 @@ const pkg = require('../package.json') module.exports = configure(api => { /** - * @type {import('.').Implements} + * @type {import('.').Implements} */ async function version (options = {}) { const res = await api.post('version', { diff --git a/packages/ipfs-message-port-client/package.json b/packages/ipfs-message-port-client/package.json index 5f5792c11f..f91921b1c9 100644 --- a/packages/ipfs-message-port-client/package.json +++ b/packages/ipfs-message-port-client/package.json @@ -19,7 +19,8 @@ "typesVersions": { "*": { "*": [ - "dist/*" + "dist/*", + "dist/*/index" ] } }, diff --git a/packages/ipfs-message-port-protocol/package.json b/packages/ipfs-message-port-protocol/package.json index 15bc37ea3c..7b61d5931c 100644 --- a/packages/ipfs-message-port-protocol/package.json +++ b/packages/ipfs-message-port-protocol/package.json @@ -16,7 +16,8 @@ "typesVersions": { "*": { "*": [ - "dist/*" + "dist/*", + "dist/*/index" ] } }, diff --git a/packages/ipfs-message-port-server/package.json b/packages/ipfs-message-port-server/package.json index 574fe88e9d..731cedd33c 100644 --- a/packages/ipfs-message-port-server/package.json +++ b/packages/ipfs-message-port-server/package.json @@ -20,7 +20,8 @@ "typesVersions": { "*": { "*": [ - "dist/*" + "dist/*", + "dist/*/index" ] } }, diff --git a/packages/ipfs/package.json b/packages/ipfs/package.json index 57d7c2a996..a03cee4fec 100644 --- a/packages/ipfs/package.json +++ b/packages/ipfs/package.json @@ -76,7 +76,8 @@ "typesVersions": { "*": { "*": [ - "dist/*" + "dist/*", + "dist/*/index" ] } }, diff --git a/packages/ipfs/src/index.js b/packages/ipfs/src/index.js index 7ed2b742f8..0ca85a967e 100644 --- a/packages/ipfs/src/index.js +++ b/packages/ipfs/src/index.js @@ -1,7 +1,5 @@ 'use strict' -// TODO: Fix TS issue that prevents use of require('ipfs-core') instead -// https://github.com/ipfs/js-ipfs/issues/3358 -const IPFS = require('ipfs-core/src') +const IPFS = require('ipfs-core') module.exports = IPFS