wevm / viem

TypeScript Interface for Ethereum
https://viem.sh
Other
2.51k stars 797 forks source link

skipLibCheck in tsconfig should not be a build requirement #2521

Closed mountainpath9 closed 2 months ago

mountainpath9 commented 2 months ago

Check existing issues

Viem Version

2.17.9

Current Behavior

Errors when compiling the npm packaged library:

node_modules/viem/_types/clients/decorators/public.d.ts:1015:426 - error TS2344: Type 'request' does not satisfy the constraint 'PrepareTransactionRequestRequest<Chain, chainOverride, DeriveChain<Chain, chainOverride>>'.
  Type 'PrepareTransactionRequestRequest<chain, chainOverride>' is not assignable to type 'PrepareTransactionRequestRequest<Chain, chainOverride, DeriveChain<Chain, chainOverride>>'.
    Type 'PrepareTransactionRequestRequest<chain, chainOverride>' is not assignable to type 'UnionOmit<ExtractChainFormatterParameters<DeriveChain<Chain, chainOverride>, "transactionRequest", TransactionRequest>, "from">'.
      Type 'request' is not assignable to type 'UnionOmit<ExtractChainFormatterParameters<DeriveChain<Chain, chainOverride>, "transactionRequest", TransactionRequest>, "from">'.
        Type 'PrepareTransactionRequestRequest<chain, chainOverride>' is not assignable to type 'UnionOmit<ExtractChainFormatterParameters<DeriveChain<Chain, chainOverride>, "transactionRequest", TransactionRequest>, "from">'.

1015     prepareTransactionRequest: <const request extends PrepareTransactionRequestRequest<chain, chainOverride>, chainOverride extends Chain | undefined = undefined, accountOverride extends Account | Address | undefined = undefined>(args: PrepareTransactionRequestParameters<chain, account, chainOverride, accountOverride, request>) => Promise<PrepareTransactionRequestReturnType<Chain, account, chainOverride, accountOverride, request>>;
                                                                                                                                                                                                                                                                                                                                                                                                                                              ~~~~~~~

node_modules/viem/_types/clients/decorators/wallet.d.ts:164:426 - error TS2344: Type 'request' does not satisfy the constraint 'PrepareTransactionRequestRequest<Chain, chainOverride, DeriveChain<Chain, chainOverride>>'.
  Type 'PrepareTransactionRequestRequest<chain, chainOverride>' is not assignable to type 'PrepareTransactionRequestRequest<Chain, chainOverride, DeriveChain<Chain, chainOverride>>'.
    Type 'PrepareTransactionRequestRequest<chain, chainOverride>' is not assignable to type 'UnionOmit<ExtractChainFormatterParameters<DeriveChain<Chain, chainOverride>, "transactionRequest", TransactionRequest>, "from">'.
      Type 'request' is not assignable to type 'UnionOmit<ExtractChainFormatterParameters<DeriveChain<Chain, chainOverride>, "transactionRequest", TransactionRequest>, "from">'.
        Type 'PrepareTransactionRequestRequest<chain, chainOverride>' is not assignable to type 'UnionOmit<ExtractChainFormatterParameters<DeriveChain<Chain, chainOverride>, "transactionRequest", TransactionRequest>, "from">'.

164     prepareTransactionRequest: <const request extends PrepareTransactionRequestRequest<chain, chainOverride>, chainOverride extends Chain | undefined = undefined, accountOverride extends Account | Address | undefined = undefined>(args: PrepareTransactionRequestParameters<chain, account, chainOverride, accountOverride, request>) => Promise<PrepareTransactionRequestReturnType<Chain, account, chainOverride, accountOverride, request>>;
                                                                                                                                                                                                                                                                                                                                                                                                                                             ~~~~~~~

node_modules/viem/_types/types/utils.d.ts:184:67 - error TS2536: Type '_K' cannot be used to index type 'fallback'.

184     [_K in Exclude<keys, keyof Item>]?: fallback extends object ? fallback[_K] : undefined;
                                                                      ~~~~~~~~~~~~

Found 3 errors in 3 files.

Errors  Files
     1  node_modules/viem/_types/clients/decorators/public.d.ts:1015
     1  node_modules/viem/_types/clients/decorators/wallet.d.ts:164
     1  node_modules/viem/_types/types/utils.d.ts:184

Expected Behavior

A clean compilation without errors

Steps To Reproduce

Run tsc in the linked minimal reproduceable example:

git clone git@github.com:mountainpath9/viem-test.git
cd viem-test
yarn
yarn tsc --noEmit

Link to Minimal Reproducible Example

https://github.com/mountainpath9/viem-test

Anything else?

Disabling error checking of the library by setting "skipLibCheck": true in tsconfig.json works around the problem.