Cannot find name 'artifacts', 'contract' after upgrading to typechain v2 [truffle v5]
See original GitHub issueHey, First and foremost, thank you so much for everyone’s work here. It’s great and extremely helpful.
I’ve built a dapp boilerplate and I’ve been upgrading it recently to have something a bit different. Throughout that, I’ve upgraded typechain to v2, and all the other dependencies attached to it. But because of that, I now get some errors as described below.
Could you guys help me, please? I’ll be very thankful.
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
TSError: ⨯ Unable to compile TypeScript:
test/SimpleStorage.test.ts:4:23 - error TS2304: Cannot find name 'artifacts'.
4 const SimpleStorage = artifacts.require('SimpleStorage');
~~~~~~~~~
test/SimpleStorage.test.ts:8:1 - error TS2304: Cannot find name 'contract'.
8 contract('SimpleStorage', (accounts) => {
~~~~~~~~
test/SimpleStorage.test.ts:8:28 - error TS7006: Parameter 'accounts' implicitly has an 'any' type.
8 contract('SimpleStorage', (accounts) => {
~~~~~~~~
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Cannot find name 'artifacts', 'contract' after upgrading ... - GitHub
I've built a dapp boilerplate and I've been upgrading it recently to have something a bit different. Throughout that, I've upgraded typechain to...
Read more >Truffle migration with TypeScript - Ethereum Stack Exchange
migrations/2_deploy_contracts.ts:10:18 - error TS2304: Cannot find name 'artifacts'. 10 const Fallback = artifacts.require('Fallback');.
Read more >Truffle can not find artifacts error | Edureka Community
I have written a smart contract and try to run it using truffle. When I try to migrate the project, I am getting...
Read more >hardhat-typechain - 登链社区
TypeChain gives you Typescript bindings for your smart contracts. Now, your tests and frontend code can be typesafe and magically autocomplete smart contract...
Read more >Typescript Test Support with Typechain/truffle-v5 type mismatch
Hey guys! I'm trying to enable typescript support for my ERC1155 Upgradable via @typechain/truffle-v5. It is a bit of an overhead since ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The way I fixed this was to use the tsconfig.json file here
https://github.com/ethereum-ts/truffle-typechain-example/blob/master/tsconfig.json
And then I changed
truffle-contracts
totruffle-typings
, undertypes
.You will need the
truffle-typings
package installed in your project.Having the exact same issue…
I had a similar issue with another project using jest, and the solution was something along the lines of adding the global libraries in the jest config file.
The funny thing in my situation is that the linters in my IDE are perfectly happy… They get all the types fine, autocomplete and everything.
But when I run truffle test all of the assumed global variables dealing with truffle / the generated types are forgotten apparently.