Skip to content

Support strict function types #8

@macalinao

Description

@macalinao

Using tsconfig strict gives an error with the Provider type. I had to implement the following to silence the error:

diff --git a/node_modules/@compound-finance/compound-js/dist/nodejs/types/index.d.ts b/node_modules/@compound-finance/compound-js/dist/nodejs/types/index.d.ts
index 9fa7d65..6fa7580 100644
--- a/node_modules/@compound-finance/compound-js/dist/nodejs/types/index.d.ts
+++ b/node_modules/@compound-finance/compound-js/dist/nodejs/types/index.d.ts
@@ -71,15 +71,13 @@ export interface ProviderNetwork {
     id?: number;
     name?: string;
 }
-declare type GenericGetBalance = (addressOrName: string | number | Promise<string | number>, blockTag?: string | number | Promise<string | number>) => Promise<BigNumber>;
-declare type GenericGetTransactionCount = (addressOrName: string | number | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>) => Promise<number>;
 declare type GenericSendTransaction = (transaction: string | Promise<string> | Deferrable<TransactionRequest>) => Promise<TransactionResponse>;
 export interface Provider extends AbstractSigner, FallbackProvider {
     connection?: Connection;
     _network: Network;
     call: AbstractSigner['call'] | FallbackProvider['call'];
-    getBalance: GenericGetBalance;
-    getTransactionCount: GenericGetTransactionCount;
+    getBalance: any;
+    getTransactionCount: any;
     resolveName: AbstractSigner['resolveName'] | FallbackProvider['resolveName'];
     sendTransaction: GenericSendTransaction;
     send?: (method: string, parameters: string[]) => any;

The solution is to treat Providers and Signers differently in the code, probably from some sort of disjoint union type. Unfortunately this may require some refactoring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions