Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistake a typing of EthereumProvider.send #2329

Closed
odanado opened this issue Feb 5, 2019 · 0 comments · Fixed by #2355
Closed

Mistake a typing of EthereumProvider.send #2329

odanado opened this issue Feb 5, 2019 · 0 comments · Fixed by #2355
Labels
Types Incorrect or missing types

Comments

@odanado
Copy link
Contributor

odanado commented Feb 5, 2019

Expected behavior

The following code is valid.

import Web3 from 'web3'
const web3 = new Web3('')
web3.currentProvider.send('', [])

Because the interface of send conforms to EIP-1193.

Actual behavior

But I got an error when running tsc --noEmit command.

Steps to reproduce the behavior

index.ts

import Web3 from 'web3'
const web3 = new Web3('')
web3.currentProvider.send('', [])

tsconfig.json

{
  "compilerOptions": {
      "module": "commonjs",
      "lib": ["es6"],
      "target": "es6",
      "noImplicitAny": true,
      "noImplicitThis": true,
      "strictNullChecks": true,
      "strictFunctionTypes": true,
      "noEmit": true,
      "allowSyntheticDefaultImports": true,
      "baseUrl": ".",
      "paths": { 
          "web3-providers": ["."] 
      }
  }
}

command

$ yarn tsc --project tsconfig.json --noEmit

Error Logs

index.ts:3:1 - error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((method: string, parameters: any[]) => Promise<object>) | ((method: string, parameters: any[]) => Promise<object>) | ((method: string, callback: () => void) => Promise<object>)' has no compatible call signatures.

5 web3.currentProvider.send('', [])
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Versions

  • npm: 5.6.0
  • node: 8.11.3
  • web3.js: 1.0.0-beta.41
  • OS: macOS High Sierra
@odanado odanado changed the title Mistake typing of EthereumProvider Mistake a typing of EthereumProvider.send Feb 5, 2019
@nivida nivida added the Types Incorrect or missing types label Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Types Incorrect or missing types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants