question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ethers-v5] Contract types not exported in generated index.ts

See original GitHub issue

The index.ts only reexports the factory types, it does not export the contract types, the ones at <ContractName>.d.ts. These types should also be exported.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:21 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
dang1412commented, Jan 31, 2022

I’m using a private npm package where the TypeChain-generated code with @typechain/ethers-v5 is exposed in that package. I’m using it in a React app (specifically a Next.js app) using TypeScript with a version >4, and I’m getting an error when it hits the export type line when I import from the root of the TypeChain output, or an error at the import type line if I try to import one of the .ts factory files directly where it imports the .d.ts file.

You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

I’m seeing if I can get Webpack to ignore the .d.ts files to get around this, but if anyone is aware of another workaround, please let me know. Thanks!

I am stucking the same thing, have you found the answer?

2reactions
tulercommented, Sep 15, 2020

Imagine you want to create a reusable npm package with the code generated by TypeChain, instead of generating it on demand in every project you want to use it.

In that case you want a package.json main key and a typescript types key with everything you typically need in the usage of package, which includes the contract types, so you can just do import { MyContract } from "my_package";.

In the current state you have to do some trickery by copying the .d.ts files over to the tsc destination directory.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[ethers-v5] Contract types not exported in generated index.ts
The index.ts only reexports the factory types, it does not export the contract types, the ones at <ContractName>.d.ts . These types should also...
Read more >
ABI Formats - ethers
There are several formats available to specify an ABI for a Smart Contract, which specifies to the under-lying library what methods, events and...
Read more >
TypeScript errors and how to fix them
error TS1208 : 'index.ts' cannot be compiled under '–isolatedModules' because it is considered a global script file. Add an import, export, ...
Read more >
How to deploy your first smart contract on Ethereum with ...
Zero Config Usage — Run the compile task as normal, and Typechain artifacts will automatically be generated in a root directory called typechain ......
Read more >
ethereum-abi-types-generator
Generate types from an ethereum ABI json file.. Latest version: 1.3.2, last published: a year ago. Start using ethereum-abi-types-generator ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found