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.

Artifacts type missing from generated typings

See original GitHub issue

I ran typechain --target=truffle-v5 --glob "build/contracts/*.json" and it generated all my typings:

ts-gen: Running TypeChain
ts-gen: build/contracts/*.json matched 2 files.
ts-gen: Processing build\contracts\Migrations.json
ts-gen: Writing file: types\truffle-contracts\Migrations.d.ts
ts-gen: Processing build\contracts\XXX.json
ts-gen: Writing file: types\truffle-contracts\XXX.d.ts
ts-gen: Writing file: types\truffle-contracts\index.d.ts
ts-gen: Writing file: types\truffle-contracts\types.d.ts
ts-gen: � All done! Generated files: 4

However in the generated types.d.ts it has this:

declare const artifacts: Truffle.Artifacts;

But there’s a red squiggle under Artifacts as it doesn’t seem to exist in the generated Truffle namespaces (it has many other definitions, like Accounts, TransactionDetails, TransactionLog).

Is this a bug, or is there something else I need to do? I thought maybe I need truffle-typings, however the readme says that’s deprecated and everything is generated here.

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, May 25, 2020

Yeah, I was using that as a reference - but started from an empty project to make sure I understood everything I was adding. I’d been bitten by weird behaviour with no tsconfig.json in the past, so not sure why it hadn’t occurred to me earlier!

FWIW, on Windows, I found that using single quotes around the glob here didn’t work:

https://github.com/ethereum-ts/TypeChain/blob/849a90f81b0753def86c989e139138ea38f4721f/examples/truffle-v5/package.json#L8

If I ran the same command directly from a shell it was fine, but when running with npm run generate-types it would always say the glob matched nothing. Swapping the quotes to \" solved the issue. I’m not sure I understand that either, but if you can repro, it may be worth updating there for those using it as a reference on Windows 😃

Thanks!

0reactions
DanTupcommented, May 25, 2020

BTW:

You won’t find a sign of chai / mocha in generated typings.

These are coming from the types.d.ts file written by the target-truffle-v5 package:

https://github.com/ethereum-ts/TypeChain/blob/f63bbe3504bb82eec2d683850998d8547b05f825/packages/target-truffle-v5/static/types.d.ts#L4-L11

https://github.com/ethereum-ts/TypeChain/blob/f63bbe3504bb82eec2d683850998d8547b05f825/packages/target-truffle-v5/src/index.ts#L49-L60

This results in expect being a chai interface automatically in all test files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find name 'artifacts', 'contract' after upgrading ... - GitHub
Based on the error messages it looks like tsc didn't pick up generated typings. Can u show us your tsconfig.json file? Do you...
Read more >
java - Maven - missing artifact - Stack Overflow
I am using Spring Tool Suite Eclipse extension and have maven2 downloaded. What could cause that? Thanks. EDIT: after typing "mvn clean install ......
Read more >
Azure DevOps: Available artifact versions not showing up ...
The release works fine after typing in the required version (so the feed exists), just the dropdown is not showing available versions.
Read more >
Type Emission - Relay
Relay guide to type emission. ... These types are included in the artifacts that relay-compiler generates to describe ... Flow; TypeScript.
Read more >
Using TypeScript | Ethereum development environment for ...
It generates typing files ( *. d. ts ) based on ABI's, and it requires little to no configuration.
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