Added types in multicodec introduces issue in js-ipfs when using multicodec.getName(cid.code) because cid.code was entyped as number while getName expects CodecNumber that is subset of number.
This change addresses that issue by changing code type accordingly & updating codec type to also fix multicodec.getNumber(cid.codec).
I also have noticed that generated types had bunch fields version, codec and multihash types generated as any, that is because constructor has early returns so type annotations at the end of the constructor were ignored. This pull fixes that by moving those annotations at the top of the file instead.
Added types in multicodec introduces issue in js-ipfs when using
multicodec.getName(cid.code)
becausecid.code
was entyped as number whilegetName
expectsCodecNumber
that is subset of number.This change addresses that issue by changing
code
type accordingly & updatingcodec
type to also fixmulticodec.getNumber(cid.codec)
.I also have noticed that generated types had bunch fields
version
,codec
andmultihash
types generated asany
, that is because constructor has early returns so type annotations at the end of the constructor were ignored. This pull fixes that by moving those annotations at the top of the file instead.