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.

Building project with tsc fails due to error in Ganache typings

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
davidmurdochcommented, Feb 6, 2022

This might just be a problem with typescript versions. Are you on an old version?

0reactions
rmeissnercommented, Feb 8, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

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