Description
Summary
ipfs-unixfs-importer
: import
type declaration imports UnixFS
from the wrong location
Impact
unable to use ipfs-unixfs-importer
package in typescript projects. attempting to transpile typescript project using tsc
fails with the following error:
> tsc
node_modules/ipfs-unixfs-importer/types/src/index.d.ts:26:20 - error TS2307: Cannot find module 'ipfs-unixfs/src' or its corresponding type declarations.
26 unixfs: import("ipfs-unixfs/src").UnixFS | undefined;
~~~~~~~~~~~~~~~~~
Found 1 error.
Potential Cause
typesVersions
inpackage.json
ofipfs-unixfs
has a path mapping that checks bothtypes/*
andtypes/src/*
. RemovingtypesVersions
entirely and regenerating the type declarations yieldsunixfs: import("ipfs-unixfs").UnixFS | undefined
which solves the problem because typescript resolves the type using thetypes
property inpackage.json
. Though, i'm not sure if this is the way we want to solve the problem. I'm not sure whether downstream projects are importing types that aren't exported fromindex.d.ts
. I think ideally, using something likenpm-dts
to bundle all types into 1index.d.ts
that is made available at the root of the package tarball would remove a lot of complexity around configuring types
Somewhat related
- type declaration files are duplicated in the package
- I think that the
reset
npm script needs to delete thetypes
directory in every package because it's auto-generated. not deleting them prevents types from being regenerated