Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Broken TypeScript typings on fresh install #3777

Closed
1 task done
Butterneck opened this issue Feb 7, 2021 · 14 comments
Closed
1 task done

Broken TypeScript typings on fresh install #3777

Butterneck opened this issue Feb 7, 2021 · 14 comments

Comments

@Butterneck
Copy link

Butterneck commented Feb 7, 2021


Issue

After a fresh install of @truffle/hdwallet-provider (other packages possibly affected as well) TypeScript typings are not working correctly and compilation fails.

Steps to Reproduce

  1. npm install @truffle/hdwallet-provider web3
  2. Put inside src/index.ts:
import HDWalletProvider from "@truffle/hdwallet-provider";
console.log("Hello world!")
  1. npx typescript --esModuleInterop src/index.ts

Expected Behavior

Compilation succeeds without any issues.

Actual Results

Typecheck fails with the following errors:

node_modules/@truffle/hdwallet-provider/dist/index.d.ts:2:61 - error TS2307: Cannot find module 'ethereum-protocol'.
import { JSONRPCRequestPayload, JSONRPCErrorCallback } from "ethereum-protocol";
                                                             ~~~~~~~~~~~~~~~~~~~
node_modules/@truffle/hdwallet-provider/dist/index.d.ts:3:43 - error TS2307: Cannot find module 'web3/providers'.
import { Callback, JsonRPCResponse } from "web3/providers";
                                           ~~~~~~~~~~~~~~~~

Environment

  • Operating System: Tested on Arch Linux
  • Ethereum client:
  • Truffle version (truffle version): Truffle v5.1.65 (core: 5.1.65) Solidity v0.5.16 (solc-js) Node v15.7.0 Web3.js v1.2.9
  • node version (node --version): v15.7.0
  • npm version (npm --version): 7.4.3
@gnidan
Copy link
Contributor

gnidan commented Feb 24, 2021

Yikes! We'll have to look into this. Hopefully this is as simple as adding skipLibCheck to hdwallet-provider's tsconfig.

Thanks for reporting!

@cds-amal
Copy link
Member

cds-amal commented Jun 15, 2021

@gnidan looks like this may be related to npm 7, which comes with node 15 by default

@binzydev
Copy link

@gnidan looks like this may be related to npm 7, which comes with node 15 by default

Same problem with NPM 6 and node 14.16.0 here

@cds-amal
Copy link
Member

cds-amal commented Jul 1, 2021

Hi @binzydev,

We might have to move some types from devDependencies to dependencies so that they make it to the declarations file. As a workaround you can manually install them.

yarn add -D @types/web3@"1.0.20" @types/ethereum-protocol@"^1.0.0"  

@binzydev
Copy link

binzydev commented Jul 1, 2021

Hi @cds-amal I've got both and no luck, can you confirm you tested?

@cds-amal
Copy link
Member

cds-amal commented Jul 1, 2021

Hey @Butterneck that is weird. What is the error? Here's the text cast of my test

@cds-amal cds-amal mentioned this issue Jul 1, 2021
1 task
@notnATrue
Copy link

@cds-amal, thx, it resolves the problem.

@cds-amal
Copy link
Member

cds-amal commented Jul 2, 2021

Hi @cds-amal I've got both and no luck, can you confirm you tested?

Hello @Butterneck , some release of @types/web3 after 1.0.20 and 1.2.2 stubbed out the definition files and broke type declarations. Can you try pinning the version to 1.0.20? You can do that with

npm install @types/web3@1.0.20

@lsqproduction
Copy link
Contributor

This is fixed and released in v5.4.23

@ali-bahjati
Copy link

I am still facing the problem with the latest version of wallet provider. To solve I needed to manually install "@types/web3-provider-engine" "@types/ethereum-protocol" and lock "@types/web3" to the version mentioned above.

So I'm not sure the issue have actually been resolved.

@cds-amal
Copy link
Member

cds-amal commented May 17, 2022

Thanks for the report @ali-bahjati. I confirmed the broken behavior.

@cds-amal cds-amal reopened this May 17, 2022
@arjunpat
Copy link

Same issue

@eggplantzzz
Copy link
Contributor

Yikes! We'll have to look into this. Hopefully this is as simple as adding skipLibCheck to hdwallet-provider's tsconfig.

So it turns out this won't affect the distributed package. I tried this and manually included it in a test project. However, there is nothing in there that would affect things at compilation-time it seems.

S0AndS0 added a commit to solidity-utilities/execution-permissions that referenced this issue Nov 30, 2022
... by adding, and pinning, yet more dependencies?!

Attributions;

- trufflesuite/truffle#3777
- trufflesuite/truffle#3777 (comment)
@sukanyaparashar
Copy link
Contributor

This should be fixed in v5.6.9.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests