From daaeaa9b7077bf174f5943ce8eae5fde47464977 Mon Sep 17 00:00:00 2001 From: Xmader Date: Mon, 7 Dec 2020 12:30:36 -0500 Subject: [PATCH 1/8] feat: export IPFS instance type --- packages/ipfs/src/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packages/ipfs/src/index.d.ts diff --git a/packages/ipfs/src/index.d.ts b/packages/ipfs/src/index.d.ts new file mode 100644 index 0000000000..8188031963 --- /dev/null +++ b/packages/ipfs/src/index.d.ts @@ -0,0 +1,3 @@ +type IPFS = import('ipfs-core/src/components') +declare const IPFS: typeof import('ipfs-core') +export = IPFS From 5cde0a59986b69830759a92030c3ad0efa6976f2 Mon Sep 17 00:00:00 2001 From: Xmader Date: Tue, 8 Dec 2020 13:20:59 -0500 Subject: [PATCH 2/8] feat: export IPFS instance type in jsdoc --- packages/ipfs/src/index.d.ts | 3 --- packages/ipfs/src/index.js | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 packages/ipfs/src/index.d.ts diff --git a/packages/ipfs/src/index.d.ts b/packages/ipfs/src/index.d.ts deleted file mode 100644 index 8188031963..0000000000 --- a/packages/ipfs/src/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -type IPFS = import('ipfs-core/src/components') -declare const IPFS: typeof import('ipfs-core') -export = IPFS diff --git a/packages/ipfs/src/index.js b/packages/ipfs/src/index.js index 0ca85a967e..2783976537 100644 --- a/packages/ipfs/src/index.js +++ b/packages/ipfs/src/index.js @@ -2,4 +2,8 @@ const IPFS = require('ipfs-core') +/** + * @typedef {import('ipfs-core/src/components')} IPFS + */ + module.exports = IPFS From 6dff4061b844b2eeda915041bf3abb539e2a1c74 Mon Sep 17 00:00:00 2001 From: Xmader Date: Mon, 14 Dec 2020 12:22:59 -0500 Subject: [PATCH 3/8] feat: export IPFS instance type in both `ipfs` and `ipfs-core` as default --- packages/ipfs-core/src/index.js | 4 ++++ packages/ipfs/src/index.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/ipfs-core/src/index.js b/packages/ipfs-core/src/index.js index bef8d923e3..4d1826b9e1 100644 --- a/packages/ipfs-core/src/index.js +++ b/packages/ipfs-core/src/index.js @@ -13,6 +13,10 @@ const multihash = multihashing.multihash const CID = require('cids') const IPFS = require('./components') +/** + * @typedef {import('./components')} default + */ + module.exports = { create: IPFS.create, crypto, diff --git a/packages/ipfs/src/index.js b/packages/ipfs/src/index.js index 2783976537..81e11b85f4 100644 --- a/packages/ipfs/src/index.js +++ b/packages/ipfs/src/index.js @@ -3,7 +3,7 @@ const IPFS = require('ipfs-core') /** - * @typedef {import('ipfs-core/src/components')} IPFS + * @typedef {import('ipfs-core/src/components')} IPFS default */ module.exports = IPFS From 0dfe6d28de50dcb0ea575c421b65b6af5c38952a Mon Sep 17 00:00:00 2001 From: Xmader Date: Mon, 14 Dec 2020 15:01:14 -0500 Subject: [PATCH 4/8] refactor: simplify exports --- packages/ipfs-core/src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ipfs-core/src/index.js b/packages/ipfs-core/src/index.js index 4d1826b9e1..424d2d3623 100644 --- a/packages/ipfs-core/src/index.js +++ b/packages/ipfs-core/src/index.js @@ -11,14 +11,14 @@ const multicodec = require('multicodec') const multihashing = require('multihashing-async') const multihash = multihashing.multihash const CID = require('cids') -const IPFS = require('./components') +const { create } = require('./components') /** * @typedef {import('./components')} default */ module.exports = { - create: IPFS.create, + create, crypto, isIPFS, CID, From cdd60e3451088100dac26a9ec12c2255b53a1d9f Mon Sep 17 00:00:00 2001 From: Xmader Date: Mon, 14 Dec 2020 15:07:13 -0500 Subject: [PATCH 5/8] doc: explain jsdoc --- packages/ipfs-core/src/index.js | 5 +++++ packages/ipfs/src/index.js | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/ipfs-core/src/index.js b/packages/ipfs-core/src/index.js index 424d2d3623..87dfd6ed24 100644 --- a/packages/ipfs-core/src/index.js +++ b/packages/ipfs-core/src/index.js @@ -14,6 +14,11 @@ const CID = require('cids') const { create } = require('./components') /** + * Export IPFS instance type + * + * This will result in `export default import("./components")` + * in the generated `d.ts` file + * * @typedef {import('./components')} default */ diff --git a/packages/ipfs/src/index.js b/packages/ipfs/src/index.js index 81e11b85f4..3528959325 100644 --- a/packages/ipfs/src/index.js +++ b/packages/ipfs/src/index.js @@ -3,7 +3,12 @@ const IPFS = require('ipfs-core') /** - * @typedef {import('ipfs-core/src/components')} IPFS default + * Export IPFS instance type + * + * This will overlap onto the default export + * in the generated `d.ts` file + * + * @typedef {import('ipfs-core').default} IPFS */ module.exports = IPFS From d3e2cfed5286e580d5488b8d538b4214701e2d55 Mon Sep 17 00:00:00 2001 From: Xmader Date: Mon, 14 Dec 2020 15:18:52 -0500 Subject: [PATCH 6/8] refactor: get rid of confusing namespace overlapping --- packages/ipfs/src/index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/ipfs/src/index.js b/packages/ipfs/src/index.js index 3528959325..fe81f298f1 100644 --- a/packages/ipfs/src/index.js +++ b/packages/ipfs/src/index.js @@ -1,14 +1,12 @@ 'use strict' -const IPFS = require('ipfs-core') +module.exports = require('ipfs-core') /** * Export IPFS instance type * - * This will overlap onto the default export + * This will result in `export default …` * in the generated `d.ts` file - * - * @typedef {import('ipfs-core').default} IPFS */ - -module.exports = IPFS +// @ts-ignore duplicate identifier +/** @typedef {import('ipfs-core').default} default */ From 2405c1cd3157006b904b97cef33ce3fd84dabf4b Mon Sep 17 00:00:00 2001 From: Xmader Date: Mon, 14 Dec 2020 15:31:04 -0500 Subject: [PATCH 7/8] fix: type generation --- packages/ipfs/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ipfs/src/index.js b/packages/ipfs/src/index.js index fe81f298f1..dc13197d8a 100644 --- a/packages/ipfs/src/index.js +++ b/packages/ipfs/src/index.js @@ -9,4 +9,4 @@ module.exports = require('ipfs-core') * in the generated `d.ts` file */ // @ts-ignore duplicate identifier -/** @typedef {import('ipfs-core').default} default */ +/** @typedef {import('ipfs-core/src/components')} default */ From 76939dd0946b53dd07d586896ac610af79fcabfb Mon Sep 17 00:00:00 2001 From: Xmader Date: Mon, 14 Dec 2020 15:37:23 -0500 Subject: [PATCH 8/8] Revert "refactor: get rid of confusing namespace overlapping" --- packages/ipfs/src/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/ipfs/src/index.js b/packages/ipfs/src/index.js index dc13197d8a..3528959325 100644 --- a/packages/ipfs/src/index.js +++ b/packages/ipfs/src/index.js @@ -1,12 +1,14 @@ 'use strict' -module.exports = require('ipfs-core') +const IPFS = require('ipfs-core') /** * Export IPFS instance type * - * This will result in `export default …` + * This will overlap onto the default export * in the generated `d.ts` file + * + * @typedef {import('ipfs-core').default} IPFS */ -// @ts-ignore duplicate identifier -/** @typedef {import('ipfs-core/src/components')} default */ + +module.exports = IPFS