Skip to content

ipfs-unixfs-importer: import type declaration imports UnixFS from the wrong location #214

Closed
@mistermoe

Description

@mistermoe

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 in package.json of ipfs-unixfs has a path mapping that checks both types/* and types/src/*. Removing typesVersions entirely and regenerating the type declarations yields unixfs: import("ipfs-unixfs").UnixFS | undefined which solves the problem because typescript resolves the type using the types property in package.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 from index.d.ts. I think ideally, using something like npm-dts to bundle all types into 1 index.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
    image
  • I think that the reset npm script needs to delete the types directory in every package because it's auto-generated. not deleting them prevents types from being regenerated

Metadata

Metadata

Assignees

No one assigned

    Labels

    need/triageNeeds initial labeling and prioritizationreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions