Skip to content

Commit ee81930

Browse files
committed
fix: more typescript type fixes
1 parent a3b4ff3 commit ee81930

File tree

10 files changed

+2
-25
lines changed

10 files changed

+2
-25
lines changed

packages/ipfs-unixfs-exporter/src/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@ const cidAndRest = (path) => {
3232
if (path instanceof Uint8Array) {
3333
console.log('vmx: index: path:', path)
3434
return {
35-
// @ts-ignore
3635
cid: CID.decode(path),
3736
toResolve: []
3837
}
3938
}
4039

41-
// @ts-ignore
4240
const cid = CID.asCID(path)
4341
if (cid) {
4442
return {
@@ -55,7 +53,6 @@ const cidAndRest = (path) => {
5553
const output = toPathComponents(path)
5654

5755
return {
58-
// @ts-ignore
5956
cid: CID.parse(output[0]),
6057
toResolve: output.slice(1)
6158
}

packages/ipfs-unixfs-exporter/src/resolvers/dag-cbor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const resolve = async (cid, name, path, toResolve, resolve, depth, blockService,
2626
toResolve.shift()
2727
subPath = `${subPath}/${prop}`
2828

29-
// @ts-ignore
3029
const subObjectCid = CID.asCID(subObject[prop])
3130
if (subObjectCid) {
3231
return {

packages/ipfs-unixfs-exporter/src/resolvers/identity.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ const resolve = async (cid, name, path, toResolve, resolve, depth, blockService,
3636
if (toResolve.length) {
3737
throw errCode(new Error(`No link named ${path} found in raw node ${cid.toString()}`), 'ERR_NOT_FOUND')
3838
}
39-
// @ts-ignore
4039
const buf = await mh.decode(cid.multihash.bytes)
4140

4241
return {
4342
entry: {
4443
type: 'identity',
4544
name,
4645
path,
47-
// @ts-ignore
4846
cid,
4947
content: rawContent(buf.digest),
5048
depth,

packages/ipfs-unixfs-exporter/src/resolvers/raw.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ const resolve = async (cid, name, path, toResolve, resolve, depth, blockService,
4242
type: 'raw',
4343
name,
4444
path,
45-
// @ts-ignore
4645
cid,
4746
content: rawContent(block.bytes),
4847
depth,
4948
// TODO vmx 2021-03-24: Check if `size` is needed
5049
size: 0,
51-
// @ts-ignore
5250
node: block.bytes
5351
}
5452
}

packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ const unixFsResolver = async (cid, name, path, toResolve, resolve, depth, blockS
9797
type: unixfs.isDirectory() ? 'directory' : 'file',
9898
name,
9999
path,
100-
// @ts-ignore
101100
cid,
102101
// @ts-ignore
103102
content: contentExporters[unixfs.type](cid, node, unixfs, path, resolve, depth, blockService),

packages/ipfs-unixfs-importer/src/dag-builder/file/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
} = require('@ipld/dag-pb')
1111
const parallelBatch = require('it-parallel-batch')
1212
const mc = require('multicodec')
13-
const mh = require('multiformats/hashes/digest')
13+
//const mh = require('multiformats/hashes/digest')
1414
const rawCodec = require('multiformats/codecs/raw')
1515

1616
/**
@@ -92,14 +92,13 @@ const reduce = (file, block, options) => {
9292
data: buffer
9393
})
9494

95-
// @ts-ignore
96-
const multihash = mh.decode(leaf.cid.multihash.bytes)
9795
buffer = encode(prepare({ Data: leaf.unixfs.marshal() }))
9896

9997
//// TODO vmx 2021-03-26: This is what the original code does, it checks
10098
//// the multihash of the original leaf node and uses then the same
10199
//// hasher. i wonder if that's really needed or if we could just use
102100
//// the hasher from `options.hasher` instead.
101+
//const multihash = mh.decode(leaf.cid.multihash.bytes)
103102
//let hasher
104103
//switch multihash {
105104
// case sha256.code {

packages/ipfs-unixfs-importer/src/dir-flat.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,13 @@ class DirFlat extends Dir {
102102
}
103103
}
104104

105-
// @ts-ignore - TODO vmx 2021-03-24: figure out what's wrong and fix it
106105
const unixfs = new UnixFS({
107106
type: 'directory',
108107
mtime: this.mtime,
109108
mode: this.mode
110109
})
111110

112111
/** @type {PbNode} */
113-
// @ts-ignore - TODO vmx 2021-03-27: fix this
114112
const node = { Data: unixfs.marshal(), Links: links }
115113
const buffer = encode(prepare(node))
116114
const cid = await persist(buffer, block, this.options)
@@ -122,7 +120,6 @@ class DirFlat extends Dir {
122120
(acc, curr) => acc + curr.Tsize,
123121
0)
124122

125-
// @ts-ignore - TODO vmx 2021-03-27: fix this
126123
this.cid = cid
127124
this.size = size
128125

packages/ipfs-unixfs-importer/src/utils/persist.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ const persist = async (buffer, block, options) => {
2222
}
2323

2424
const multihash = await options.hasher.digest(buffer)
25-
// TODO vmx 2021-02-24: no idea why TypeScript fails here, it should work
26-
// @ts-ignore
2725
const cid = CID.create(options.cidVersion, options.codec, multihash)
2826

2927
if (!options.onlyHash) {
3028
await block.put({
31-
// @ts-ignore TODO vmx 2021-03-17
3229
bytes: buffer,
3330
cid
3431
}, {

packages/ipfs-unixfs-importer/test/builder-balanced.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const options = {
3131
describe('builder: balanced', () => {
3232
it('reduces one value into itself', async () => {
3333
const source = [{
34-
// @ts-ignore - TODO vmx 2021-03-25: fix: error TS2339: Property 'parse' does not exist on type 'typeof import("/js-multiformats/dist/types/cid")'
3534
cid: CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'),
3635
size: 0
3736
}]
@@ -45,15 +44,12 @@ describe('builder: balanced', () => {
4544

4645
it('reduces 3 values into parent', async () => {
4746
const source = [{
48-
// @ts-ignore - TODO vmx 2021-03-25: fix: error TS2339: Property 'parse' does not exist on type 'typeof import("/js-multiformats/dist/types/cid")'
4947
cid: CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'),
5048
size: 0
5149
}, {
52-
// @ts-ignore - TODO vmx 2021-03-25: fix: error TS2339: Property 'parse' does not exist on type 'typeof import("/js-multiformats/dist/types/cid")'
5350
cid: CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'),
5451
size: 0
5552
}, {
56-
// @ts-ignore - TODO vmx 2021-03-25: fix: error TS2339: Property 'parse' does not exist on type 'typeof import("/js-multiformats/dist/types/cid")'
5753
cid: CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'),
5854
size: 0
5955
}]

packages/ipfs-unixfs-importer/test/builder.spec.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ describe('builder', () => {
3131

3232
const result = await first(builder([inputFile], block, {
3333
...defaultOptions(),
34-
// @ts-ignore thinks these aren't valid hash alg names
3534
hasher
3635
}))
3736

@@ -68,7 +67,6 @@ describe('builder', () => {
6867

6968
const result = await first(builder([inputFile], block, {
7069
...defaultOptions(),
71-
// @ts-ignore thinks these aren't valid hash alg names
7270
hasher
7371
}))
7472

@@ -92,7 +90,6 @@ describe('builder', () => {
9290

9391
const result = await first(builder([{ ...inputFile }], block, {
9492
...defaultOptions(),
95-
// @ts-ignore thinks these aren't valid hash alg names
9693
hasher
9794
}))
9895

0 commit comments

Comments
 (0)