coinbase / onchainkit

React components and TypeScript utilities to help you build top-tier onchain apps.
https://onchainkit.xyz
MIT License
426 stars 78 forks source link

Bug: type declarations not available have to use @coinbase/onchainkit/esm/* #695

Closed blmalone closed 1 week ago

blmalone commented 1 week ago

Describe the bug and the steps to reproduce it

When importing ConnectAccount:

import { ConnectAccount } from '@coinbase/onchainkit/wallet';

I get the following error:

Cannot find module '@coinbase/onchainkit/wallet' or its corresponding type declarations.ts(2307)

Below is a screenshot of the error:

Screenshot 2024-06-24 at 13 40 14

Below is a screenshot when the error is resolved:

Screenshot 2024-06-24 at 13 42 39

Fix: I had to directly use esm in my import statement.

What's the expected behavior?

Shouldn't have to use esm import. Or if I do, this should require a documentation update on your end.

What version of the libraries are you using?

^0.22.2

kyhyco commented 1 week ago

It should work as @coinbase/onchainkit/wallet.

I can't reproduce this issue on the sample app.

Could you show me your tsconfig?

kyhyco commented 1 week ago

That is to say, we only build for esm so let's make sure that your tsconfig is correct. Will update the docs afterwards.

kyhyco commented 1 week ago

FYI we are updating @coinbase/onchainkit/wallet as we speak. It doesn't work that great as-is.

kyhyco commented 1 week ago

Here is a sneak peak at what we are cooking up!

Screenshot 2024-06-24 at 9 06 06 PM
blmalone commented 1 week ago

@kyhyco Those updates look cool. Here's my tsconfig.ts:

{
  "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "lib": ["dom", "es2017"],
    "jsx": "react",
    "strict": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": ["src"]
}
kyhyco commented 1 week ago

could you try with these?

{
  "compilerOptions": {
    // ...
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    // ...
  }
}
blmalone commented 1 week ago

Getting the same error:

Screenshot 2024-06-25 at 19 17 41
blmalone commented 1 week ago

@kyhyco here's the repo I'm working with: https://github.com/blmalone/cafebabe

kyhyco commented 1 week ago

In middle of making the new ConnectWallet component. I will take a look at this after I make some progress on the new component!

kyhyco commented 1 week ago

Aight try this:

{
  "compilerOptions": {
    "target": "ES2020",
    "lib": ["DOM", "DOM.Iterable", "esnext"],
    "allowImportingTsExtensions": true,
    "isolatedModules": true,
    "jsx": "react-jsx",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "noEmit": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strict": true,
    "useDefineForClassFields": true
  },
  "include": ["src"]
}
blmalone commented 1 week ago

Thanks for the reply. I tried your suggestion and I'm getting:

🚨 Build failed.

@parcel/core: Failed to resolve '@coinbase/onchainkit/identity' from './src/components/Home.tsx'

  /Users/blaine/code/cafebabe/web/src/components/Home.tsx:22:33
    21 | import { ConnectAccount } from "@coinbase/onchainkit/wallet";
  > 22 | import { Avatar, Address } from "@coinbase/onchainkit/identity";
  >    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    23 | import {
    24 |   useAccount,

I believe this has something to do with parcel the build tool we're using: https://parceljs.org/

kyhyco commented 1 week ago

Ah can't help you there. Don't know how parcel works.

kyhyco commented 1 week ago

@blmalone I recommend this though https://tailwindcss.com/docs/guides/vite

Make a new project using that guide which will setup vite (parcel alternative) for you out of the box.

Follow, onchainkit installation instructions and copy all the files from the old project into this new one.