nknorg / nkn-sdk-js

JavaScript Implementation of NKN Client and Wallet SDK
Apache License 2.0
43 stars 17 forks source link

Type linking issue fixed with typescript #142

Closed hrishioa closed 5 months ago

hrishioa commented 5 months ago

package.json has an issue where Typescript wasn't able to pick up types.

To reproduce, you can try importing nkn-sdk as per the example into a fresh create-next-app project (and running npm build). This was the error:

next build
  ▲ Next.js 14.2.3

   Creating an optimized production build ...
 ✓ Compiled successfully
   Linting and checking validity of types  ...Failed to compile.

./src/core/p2p/nkn-test.ts:1:45
Type error: Could not find a declaration file for module 'nkn-sdk'. '<project>/node_modules/nkn-sdk/lib/index.js' implicitly has an 'any' type.
  There are types at <project>/node_modules/nkn-sdk/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'nkn-sdk' library may need to update its package.json or typings.

> 1 | import { Client, MultiClient, Wallet } from "nkn-sdk";

error: script "build" exited with code 1

Small change to package.json fixes it!