Closed ukstv closed 3 years ago
Which version of the module are you using? Types only arrived in v2.
2.0.5
I've cloned the project and run the bootstrap command. You have many duplicate versions of the uint8arrays
module, most of which are 1.x which doesn't have types.
tsc
is probably finding these old versions which is why you're seeing that error.
$ find . -type d -name uint8arrays
./node_modules/multicodec/node_modules/uint8arrays
./node_modules/@textile/powergate-client/node_modules/uint8arrays
./node_modules/@glif/local-managed-provider/node_modules/uint8arrays
./node_modules/@glif/filecoin-address/node_modules/uint8arrays
./node_modules/libp2p-record/node_modules/uint8arrays
./node_modules/libp2p-record/node_modules/multihashing-async/node_modules/uint8arrays
./node_modules/peer-id/node_modules/multicodec/node_modules/uint8arrays
./node_modules/peer-id/node_modules/libp2p-crypto/node_modules/uint8arrays
./node_modules/ipld-dag-pb/node_modules/uint8arrays
./node_modules/ipld-dag-pb/node_modules/multihashing-async/node_modules/uint8arrays
./node_modules/dag-jose/node_modules/uint8arrays
./node_modules/protons/node_modules/uint8arrays
./node_modules/libp2p-crypto/node_modules/uint8arrays
./node_modules/libp2p-crypto/node_modules/multihashing-async/node_modules/uint8arrays
./node_modules/multistream-select/node_modules/uint8arrays
./node_modules/dag-jose-utils/node_modules/uint8arrays
./node_modules/ipfs-http-client/node_modules/uint8arrays
./node_modules/libp2p-kad-dht/node_modules/multicodec/node_modules/uint8arrays
./node_modules/libp2p-kad-dht/node_modules/libp2p-crypto/node_modules/uint8arrays
./node_modules/ipfs-core-utils/node_modules/uint8arrays
./node_modules/cids/node_modules/uint8arrays
./node_modules/libp2p-floodsub/node_modules/uint8arrays
./node_modules/key-did-provider-ed25519/node_modules/uint8arrays
./node_modules/dids/node_modules/uint8arrays
./node_modules/multiaddr/node_modules/uint8arrays
./node_modules/ipfs-unixfs-importer/node_modules/uint8arrays
./node_modules/ipfs-unixfs-importer/node_modules/multihashing-async/node_modules/uint8arrays
./node_modules/ipld-dag-cbor/node_modules/uint8arrays
./node_modules/ipld-dag-cbor/node_modules/multihashing-async/node_modules/uint8arrays
./node_modules/uint8arrays
./node_modules/is-ipfs/node_modules/uint8arrays
./node_modules/ipns/node_modules/libp2p-crypto/node_modules/uint8arrays
./node_modules/libp2p-noise/node_modules/libp2p-crypto/node_modules/uint8arrays
./node_modules/libp2p-gossipsub/node_modules/uint8arrays
./node_modules/libp2p-interfaces/node_modules/libp2p-crypto/node_modules/uint8arrays
./node_modules/libp2p/node_modules/uint8arrays
./node_modules/ipfs-core/node_modules/uint8arrays
./node_modules/ipfs-core/node_modules/multihashing-async/node_modules/uint8arrays
e.g.:
$ cat node_modules/key-did-provider-ed25519/node_modules/uint8arrays/package.json | grep version
"version": "1.1.0"
For all of them:
$ find . -type d -name uint8arrays | xargs -n 1 sh -c 'cat $0/package.json' | grep version
"type": "version",
"version": "1.0.0"
"version": "1.1.0"
"version": "1.1.0"
"type": "version",
"version": "1.1.0"
"version": "1.1.0"
"version": "2.0.5"
"type": "version",
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "2.0.5"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "2.0.5"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"type": "version",
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "2.0.5"
"version": "1.1.0"
"version": "2.0.5"
"version": "2.0.5"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "1.1.0"
"version": "2.0.5"
It might be true. I believe it is irrelevant, as it fails on pristine setup: https://github.com/ukstv/u8a-ts npm install && npm run build
here shows the error. tsconfig is unchanged from tsc --init
.
Ah, that's interesting, I don't tend to import the whole module like:
import * as ui8 from 'uint8arrays'
more individual functions like:
import fromString from 'uint8arrays/from-string'
..which I think is why it was working for me and not for you.
Anyway thanks for the tiny project, it's helped me figure out what I think is a fix - please try uint8arrays@2.1.1
, it seems to work all these styles of import in u8a-ts
:
import * as ui8 from 'uint8arrays'
import toString from 'uint8arrays/to-string'
import { fromString } from 'uint8arrays'
console.log(ui8)
console.log(toString)
console.log(fromString)
Works now! Thanks @achingbrain a lot!!
I use the package with vanilla tsconfig.json (i.e. after
tsc --init
). It fails to compile:Something is wrong with the exposed type declarations.