Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

[ipfs-http-client@52.0.2] Typescript compilation fails when package is imported #3839

Closed
rryter opened this issue Aug 27, 2021 · 4 comments
Closed
Labels
need/author-input Needs input from the original author

Comments

@rryter
Copy link

rryter commented Aug 27, 2021

  • Version:
    "ipfs-http-client": "52.0.2",

  • Platform:
    Ubuntu 20.04

  • Subsystem:
    Typescript 4.3.5

Severity:

Critical - Comilation fails as soon as the package is imported.

Description:

node_modules/ipfs-utils/dist/src/files/glob-source.d.ts:10:20
error TS2307: Cannot find module 'ipfs-unixfs/dist/src/types' or its corresponding type declarations.

10     mtime?: import("ipfs-unixfs/dist/src/types").MtimeLike | undefined;

So I checked the package in the node_modules, and there is indeed no dist folder.

Steps to reproduce the error:

npx typescript-starter
npm i ipfs-http-client
  1. Create a new file
  2. Import the Options Type
import { Options } from 'ipfs-http-client';
export interface InterfaceName {
  options: Options;
}
  1. Try to compile.

Workaround

Add postinstall to the scripts in your npm package:

"postinstall": "npm run generate-types && cd node_modules/ipfs-unixfs && npm i --production"
@rryter rryter added the need/triage Needs initial labeling and prioritization label Aug 27, 2021
@welcome
Copy link

welcome bot commented Aug 27, 2021

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@achingbrain
Copy link
Member

Looks like ipfs-utils needed it's types rebuilding with the new ESM version of ipfs-unixfs since the internal paths have changed.

This should be fixed by ipfs-utils@v8.1.6, just released - can you please delete your node_modules folder and reinstall, you should get the new version then.

@achingbrain achingbrain added need/author-input Needs input from the original author and removed need/triage Needs initial labeling and prioritization labels Aug 27, 2021
@rryter
Copy link
Author

rryter commented Aug 27, 2021

It works. Thanks a lot. 🚀

@rryter rryter closed this as completed Aug 27, 2021
rryter added a commit to lukso-network/tools-lsp-factory that referenced this issue Aug 27, 2021
rryter added a commit to lukso-network/tools-lsp-factory that referenced this issue Aug 29, 2021
chore(cleanup): fix unfinished renaming

chore(types): workaround ipfs-http-client problem

ipfs/js-ipfs#3839

chore(types): added more types for the upload feature

chore(upload): small code cleanup, do not throw on wrong file input

chore(jest): switch to jest

chore(ci): fix build

chore(ci): fix caching on ci

chore(uploader): tests, wip

chore(cleanup): wrap up alpha version of image upload
@slwhitman
Copy link

I could not get workaround to work. Core error still exists. The import path is incorrect.

Currently: import("ipfs-unixfs/types/src/types")

Should be: import("ipfs-unixfs/src/types")

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/author-input Needs input from the original author
Projects
None yet
Development

No branches or pull requests

3 participants