-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Types cannot be imported when packaged #758
Comments
having this issue as well. |
turns out this is not the correct way to use Typechain. here's what you should do instead:
|
@jgeary Ok, I can live with just packaging up the abis and then generating types from there. Not ideal imo, but its better than copy pasting abi updates then generating types. |
The problem is probably that your tsconfig (or e.g., jest config if the problem happens when running tests) doesn't include typechains types in the ts code that it should target for transpilation (typically one would exclude node_modules). So the solution is to include your package. Here's how to do it so that jest transpiles typechain types from a published package: // in jest.config.js, or `jest` in package.json, etc.
transformIgnorePatterns: ['<rootDir>/node_modules/(?!(@my-org/my-package)/)'],
// "@my-org/my-package" or simply "my-package" is your package isn't scoped |
Discussed in #755
Originally posted by rtman August 25, 2022
We're trying to make our typechain types reuseable by packaging them up as a private npm package. However this seems to cause issues like the following when in use in nextjs.
Here's the package.json for the package:
The root of the package is the output dir of typechain, containing all the types as well as the copied artifacts dir from hardhat.
I've seen a few related issues to this but no resolution yet #609 (comment) #278 (comment) , would be great to get some guidance here or a fix.
We're using
"@typechain/ethers-v5": "^10.0.0",
The text was updated successfully, but these errors were encountered: