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

Commit 839e190

Browse files
authored
fix: issue with isolateModules flag (#3495)
Fixes #3494 Fixes #3498 It appears that `react-scripts` swaps `isolateModules` which [causes problems in webui](ipfs/ipfs-webui#1655 (comment)) because according to TS: > Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'. TS1205 Changes here address that problem as follows: - `export type {...}` is used as per TS error. - `isolateModules` flag is set to `true` so that such issues can be caught locally. - Setting flags seems to have triggered problems in `ipfs-client`, so I had to add some type annotations to fix that. - Added `references` in `ipfs-client/tsconfig.json`, otherwise it does not pick up changes in the dependencies unless they are manually rebuild.
1 parent 43d5bb0 commit 839e190

File tree

7 files changed

+29
-4
lines changed

7 files changed

+29
-4
lines changed

packages/ipfs-client/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
]
2323
}
2424
},
25+
"eslintConfig": {
26+
"extends": "ipfs"
27+
},
2528
"repository": {
2629
"type": "git",
2730
"url": "git+https://github.com/ipfs/js-ipfs.git"

packages/ipfs-client/src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ const httpClient = require('ipfs-http-client')
44
const grpcClient = require('ipfs-grpc-client')
55
const mergeOptions = require('merge-options')
66

7+
/**
8+
* @typedef {import('ipfs-http-client/src/lib/core').ClientOptions} HTTPOptions
9+
* @typedef {import('ipfs-grpc-client/src/index').Options} GRPCOptions
10+
* @typedef {string|URL|import('multiaddr')} Address
11+
* @typedef {{http?: Address, grpc?: Address} & Partial<HTTPOptions & GRPCOptions>} Options
12+
*
13+
* @param {Options} [opts]
14+
*/
715
module.exports = function createClient (opts = {}) {
816
const clients = []
917

packages/ipfs-client/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
"compilerOptions": {
44
"outDir": "dist"
55
},
6+
"references": [
7+
{
8+
"path": "../ipfs-http-client"
9+
},
10+
{
11+
"path": "../ipfs-grpc-client"
12+
}
13+
],
614
"include": [
715
"src",
816
"package.json"

packages/ipfs-core-types/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { RootAPI } from './root'
22
import { AbortOptions, Await, AwaitIterable } from './basic'
33

4-
export {
4+
export type {
55
RootAPI,
66

77
AbortOptions,

packages/ipfs-grpc-client/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,8 @@
6060
"rimraf": "^3.0.2",
6161
"sinon": "^9.0.3",
6262
"typescript": "4.0.x"
63+
},
64+
"eslintConfig": {
65+
"extends": "ipfs"
6366
}
6467
}

packages/ipfs-grpc-client/src/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ function normaliseUrls (opts) {
2323
* @typedef {import('http').Agent} HttpAgent
2424
* @typedef {import('https').Agent} HttpsAgent
2525
*
26-
* @param {object} opts
27-
* @param {string} opts.url - The URL to connect to as a URL or Multiaddr
28-
* @param {HttpAgent|HttpsAgent} [opts.agent] - http.Agent used to control HTTP client behaviour (node.js only)
26+
* @typedef {Object} Options
27+
* @property {string|URL|import('multiaddr')} url - The URL to connect to as a URL or Multiaddr
28+
* @property {HttpAgent|HttpsAgent} [agent] - http.Agent used to control HTTP client behaviour (node.js only)
29+
*
30+
* @param {Options} [opts]
2931
*/
3032
module.exports = function createClient (opts = { url: '' }) {
3133
opts.url = toUrlString(opts.url)

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"stripInternal": true,
2525
"resolveJsonModule": true,
2626
"incremental": true,
27+
"isolatedModules": true,
2728
"baseUrl": ".",
2829
"paths": {
2930
"interface-ipfs-core/*": [

0 commit comments

Comments
 (0)