Skip to content

Example of integration between JS-IPFS and Typescript

Notifications You must be signed in to change notification settings

ipfs-examples/js-ipfs-types-use-ipfs-from-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IPFS in JavaScript logo

Using IPFS with Typescript

Template for using js-ipfs in typescript project


Explore the docs · View Demo · Report Bug · Request Feature/Example

Table of Contents

About The Project

Getting Started

Prerequisites

Make sure you have installed all of the following prerequisites on your development machine:

Installation and Running example

> npm install
> npm run test

Now open your console and check if has errors!

Usage

This example provides a template for using js-ipfs in typescript project.

If you remove // @ts-expect-error comment is src/main.ts on line 16 and run npm test once again you should see a following output instead:

tsc --noEmit

src/main.ts:16:14 - error TS2339: Property 'toUpperCase' does not exist on type 'CID'.

16     file.cid.toUpperCase()
                ~~~~~~~~~~~


Found 1 error.

IntelliSense

In VSCode and other code editors that provide comparable IntelliSense features you should be able to get code auto complete, parameter and return value information for js-ipfs APIs.

Preview

Limitations

  • Things should work out of the box, with most tsconfig settings, however unless skipLibCheck is set to true many errors will be reported.

    That is because types are generated from source JSDoc comments and typescript seems to emit declarations which it then complains about.

  • Not all APIs are fully typed so you might observe gaps and any types here and there. We hope to improve this over time.

For more examples, please refer to the Documentation

References

Documentation

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the IPFS Project
  2. Create your Feature Branch (git checkout -b feature/amazing-feature)
  3. Commit your Changes (git commit -a -m 'feat: add some amazing feature')
  4. Push to the Branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Want to hack on IPFS?

The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out:

Read the Code of Conduct and JavaScript Contributing Guidelines.

  • Check out existing issues The issue list has many that are marked as 'help wanted' or 'difficulty:easy' which make great starting points for development, many of which can be tackled with no prior IPFS knowledge
  • Look at the IPFS Roadmap This are the high priority items being worked on right now
  • Perform code reviews More eyes will help a. speed the project along b. ensure quality, and c. reduce possible future bugs.
  • Add tests. There can never be enough tests.
  • Join the Weekly Core Implementations Call it's where everyone discusses what's going on with IPFS and what's next

About

Example of integration between JS-IPFS and Typescript

Resources

Stars

Watchers

Forks