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

Remove optional revert error return types from web3-eth TS definitions #3504

Merged
merged 2 commits into from
May 7, 2020

Conversation

cgewecke
Copy link
Collaborator

@cgewecke cgewecke commented May 6, 2020

Description

PR removes error return types which cause tsc compilation errors when used in a statement that declares a type for the LHS of some web3-eth methods. The error isn't really a return value, it's the type of the error object passed to the catch clause.

For example:

const a: TransactionReceipt = await sendTransaction(...)

...currently throws

error TS2322: Type 'TransactionRevertInstructionError | TransactionReceipt' is not assignable 
to type 'TransactionReceipt'. Type 'TransactionRevertInstructionError' is missing 
the following properties from type 'TransactionReceipt': status, transactionHash, 
transactionIndex, blockHash, and 7 more.

(Looked around at a few TS projects to see how (or if) defining custom error types for Promise rejections is done but don't see a lot of examples. )

Fixes #3496

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run dtslint with success and extended the tests and types if necessary.
  • I have updated the CHANGELOG.md file in the root folder.

@cgewecke cgewecke added 1.x 1.0 related issues Bug Addressing a bug Types Incorrect or missing types labels May 6, 2020
@ryanio
Copy link
Collaborator

ryanio commented May 7, 2020

(Looked around at a few TS projects to see how (or if) defining custom error types for Promise rejections is done but don't see a lot of examples. )

It looks like this continues to be under discussion in microsoft/TypeScript#20024.

Otherwise, PR LGTM!

@ryanio ryanio merged commit 537d7ce into 1.x May 7, 2020
@holgerd77 holgerd77 deleted the issue/3496 branch May 8, 2020 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Bug Addressing a bug Types Incorrect or missing types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix TS promise error types in web3-eth
2 participants