Building project with tsc fails due to error in Ganache typings
See original GitHub issueI try to build a library that depends on Ganache v7. When I run tsc
I get a bunch of errors for the typings generation.
Node version: 16.9.1 (tried also with 12) Ganache version: 7.0.2
Compiler output:
yarn run v1.22.17
$ rimraf dist && tsc
node_modules/ganache/dist/ganache.d.ts:2162:8 - error TS1005: ',' expected.
2162 removed: Buffer,
~
node_modules/ganache/dist/ganache.d.ts:2163:17 - error TS1005: ',' expected.
2163 transactionIndex: Buffer,
~
node_modules/ganache/dist/ganache.d.ts:2164:16 - error TS1005: ',' expected.
2164 transactionHash: Buffer,
[...]
node_modules/ganache/dist/ganache.d.ts:12178:28 - error TS1005: ',' expected.
12178 declare type TxType = [type: Buffer];
~
node_modules/ganache/dist/ganache.d.ts:12180:25 - error TS1110: Type expected.
12180 declare type TxType_2 = `0x${HexChar}` | `0x${HexPair}`;
~~~~~
Found 81 errors.
tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true
},
"exclude": [
"node_modules",
"**/*.test.ts",
"examples"
]
}
Not sure if related to the known issues regarding typings.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Could not find a declaration file for module 'module-name'. ...
If you're importing a third-party module 'foo' that doesn't provide any typings, either in the library itself, or in the @types/foo package (generated...
Read more >TypeScript Compiling with Visual Studio Code
If you get that error, resolve it by creating a tsconfig.json file in the root folder of your project. The tsconfig.json file lets...
Read more >How to fix error TS7016: Could not find a declaration file for ...
Try `npm install @types/XYZ` if it exists or add a new declaration (.d.ts) file containing `declare module 'XYZ';. If XYZ is a direct...
Read more >ConsenSys/truffle - Gitter
Hey, have any of you had problems with HDWalletProvider typings? My code is failing TS compilation on clean install:
Read more >Alternatives for Truffle for running and writing tests
I found openzeppelin-test-environment solving my problem. It allows ephemeral Ethereum blockchain setup, contract deployment, ...
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
This might just be a problem with typescript versions. Are you on an old version?
I only found https://github.com/microsoft/TypeScript/pull/26568 on SO. You basically would set the default types to one that throws an error and overwrite for a specific version the type definition to the correct one. Seems a little hacky 😬
Edit: Docs for
typesVersion
: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#version-selection-with-typesversions