Broken syntax for generated types
See original GitHub issueI am migrating a truffle project to hardhat/typechain/trufflev5 and apparently typechain is generating types with a broken typescript syntax - the contracts should be compiled correctly as I am able to do that both in a truffle and openzeppelin environment
SyntaxError: '{' expected. (25:37)
23 |
24 |
> 25 | export interface Committed_address[] {
| ^
26 | name: "Committed"
27 | args: {
28 | whitelist : (string)[],
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
[Source Generator] Syntax highlighting partially broken by ...
Download and build the following solution: SyntaxHighlightingBug.zip. Restart Visual Studio to wire up the source generator (as is documented). Add an arbitrary ...
Read more >Documentation - Creating Types from Types - TypeScript
An overview of the ways in which you can create more types from existing types. ... Indexed Access Types - Using Type['a'] syntax...
Read more >How do you fix a broken type signature in a library for your ...
I'm using the debug and @types/debug packages in my project, and a recent update to @types/debug broke typings for code I know is...
Read more >TypeScript with GraphQL done right - Charly Poly
Stronger generated TypeScript types; Getting the most of your ... The example below shows how easily this “types chain” can be broken:.
Read more >Syntax Error - an overview | ScienceDirect Topics
Syntax errors are mistakes in the source code, such as spelling and punctuation errors, incorrect labels, and so on, which cause an error...
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
@krzkaczor Using the sample provided by Riccardo it looks like when there are event overloads and those events have array args the code outputs invalid naming. This doesn’t happen with ethers-v5 because it looks like for ethers we do not try to write both event interfaces in the overloading contract.
From sample:
These contracts for truffle-v5 and for web3-v1 create
WhitelistedWithGovernance.d.ts
fine but when it attempts to createWhitelistedWithGovernanceAndChangableTimelock.d.ts
file containing overloaded interfaces it errors:I wasn’t sure if both interfaces were to be expected or if we should have both interfaces in the types file and it will need to be renamed to something like
Committed_address_array
.I am willing to create a PR for this just wasn’t sure what is expected.
@derekarends thanks for investigating this!
I think that we should generate names with explicit names like:
Committed_address_array
, when conflicting events are detected. We already do something like this for function signatures. And there is even a flag to always generate such overrides:--always-generate-overloads
. I think you can use the same flag to control this behavior.