Skip to content
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

Generate .d.ts file #609

Closed
zeroXBami opened this issue Jan 25, 2022 · 4 comments
Closed

Generate .d.ts file #609

zeroXBami opened this issue Jan 25, 2022 · 4 comments

Comments

@zeroXBami
Copy link

zeroXBami commented Jan 25, 2022

Hi there,

As I understand, from now typechain only generate .ts file instead of .d.ts file, but when I try to import .ts file , I always get error below. And if I want to use .d.ts file? How could I generate that with current newest version ?

error - ./node_modules/.../Router__factory.ts 6:12
Module parse failed: Unexpected token (6:12)
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
| import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers";
@krzkaczor
Copy link
Member

I think you're trying to load ts file with a js loader. If you use webpack, by default it will treat files in node_modules as js.

@zeroXBami
Copy link
Author

@krzkaczor thank you, let me check, but in case if I want to have .d.ts file? What should I do ?
I m using:
"@typechain/ethers-v5": "9.0.0",
"@typechain/hardhat": "^4.0.0",
"typechain": "7.0.0"

@krzkaczor
Copy link
Member

Yes. TC generally (apart from factories...) generates only typings. You need to create runtime object and later cast it to the desired type.

Here are some examples:

Also you might find eth-sdk useful if you're interacting with already deployed, mainnet contracts.

@zeroXBami
Copy link
Author

thank you @krzkaczor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants