Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Export IPFS instance type #3439

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/ipfs-core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const multihash = multihashing.multihash
const CID = require('cids')
const IPFS = require('./components')
Xmader marked this conversation as resolved.
Show resolved Hide resolved

/**
* @typedef {import('./components')} default
Xmader marked this conversation as resolved.
Show resolved Hide resolved
*/

module.exports = {
create: IPFS.create,
crypto,
Expand Down
4 changes: 4 additions & 0 deletions packages/ipfs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

const IPFS = require('ipfs-core')
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be simpler to do this instead

Suggested change
const IPFS = require('ipfs-core')
/**
* @typedef {import(‘ipfs-core/src/components’)} IPFS
*/
module.exports = require('ipfs-core')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not work because @typedef {import('ipfs-core/src/components')} IPFS will not overlap onto the exports

Generated d.ts file:

declare const _exports: typeof import('ipfs-core/src')
export = _exports;
export type IPFS = import('ipfs-core/src/components');

We can't use

import type IPFS from "ipfs"

Copy link
Contributor

Choose a reason for hiding this comment

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

@Xmader I realize that, but point I was trying to make is, having export type IPFS is just simpler and in the nutshell will give us:

import { IPFS, create } from "ipfs"

Furthermore I expect that as we adopt approach proposed in #3413 we might end up with IPFS interface that in the future could be exported in place of IPFS type.

That said, it's an @achingbrain call


/**
* @typedef {import('ipfs-core/src/components')} IPFS default
Xmader marked this conversation as resolved.
Show resolved Hide resolved
*/

module.exports = IPFS