trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 678 forks source link

Ganache v7.0.0 - typings are broken #2134

Closed gorbak25 closed 2 years ago

gorbak25 commented 2 years ago
node_modules/ganache/dist/ganache.d.ts:16:39 - error TS2307: Cannot find module 'ipfs-core/src/components' or its corresponding type declarations.

16 import { ipfsCoreSrcComponents } from 'ipfs-core/src/components';
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/ganache/dist/ganache.d.ts:18:24 - error TS2307: Cannot find module '@filecoin-shipyard/lotus-client-schema' or its corresponding type declarations.

18 import { Schema } from '@filecoin-shipyard/lotus-client-schema';
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/ganache/dist/ganache.d.ts:19:24 - error TS2307: Cannot find module 'seedrandom' or its corresponding type declarations.

19 import seedrandom from 'seedrandom';
                          ~~~~~~~~~~~~

node_modules/ganache/dist/ganache.d.ts:3704:75 - error TS2307: Cannot find module './types/subscriptions' or its corresponding type declarations.

3704     get provider(): FilecoinProvider_2<JsonRpcRequest<FilecoinApi, import("./types/subscriptions").SubscriptionMethod.ChannelClosed | "initialize" | "stop" | "Filecoin.Version" | "Filecoin.ID" | "Filecoin.ChainGetGenesis" | "Filecoin.ChainHead" | "Filecoin.ChainNotify" | "Filecoin.ChainGetTipSet" | "Filecoin.ChainGetTipSetByHeight" | "Filecoin.ChainGetBlock" | "Filecoin.ChainGetBlockMessages" | "Filecoin.ChainGetMessage" | "Filecoin.MpoolGetNonce" | "Filecoin.MpoolPush" | "Filecoin.MpoolBatchPush" | "Filecoin.MpoolPushMessage" | "Filecoin.MpoolBatchPushMessage" | "Filecoin.MpoolClear" | "Filecoin.MpoolPending" | "Filecoin.MpoolSelect" | "Filecoin.ActorAddress" | "Filecoin.StateListMiners" | "Filecoin.StateMinerPower" | "Filecoin.StateMinerInfo" | "Filecoin.WalletDefaultAddress" | "Filecoin.WalletSetDefault" | "Filecoin.WalletBalance" | "Filecoin.WalletNew" | "Filecoin.WalletList" | "Filecoin.WalletHas" | "Filecoin.WalletDelete" | "Filecoin.WalletExport" | "Filecoin.WalletImport" | "Filecoin.WalletSign" | "Filecoin.WalletSignMessage" | "Filecoin.WalletVerify" | "Filecoin.WalletValidateAddress" | "Filecoin.ClientStartDeal" | "Filecoin.ClientListDeals" | "Filecoin.ClientGetDealInfo" | "Filecoin.ClientGetDealStatus" | "Filecoin.ClientGetDealUpdates" | "Filecoin.ClientFindData" | "Filecoin.ClientHasLocal" | "Filecoin.ClientRetrieve" | "Ganache.MineTipset" | "Ganache.EnableMiner" | "Ganache.DisableMiner" | "Ganache.MinerEnabled" | "Ganache.MinerEnabledNotify" | "Ganache.GetDealById">>;
                                                                               ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/ganache/dist/ganache.d.ts:7101:163 - error TS2344: Type 'ExclusiveGroup<C, K>' does not satisfy the constraint 'unknown[]'.
  Type 'ExclusiveGroups<C>[ExclusiveGroupIndex<C>]' is not assignable to type 'unknown[]'.
    Type 'ExclusiveGroups<C>[number]' is not assignable to type 'unknown[]'.

7101 declare type ExclusiveGroupOptionName<C extends Base.Config, K extends ExclusiveGroupIndex<C> = ExclusiveGroupIndex<C>> = Extract<OptionName<C>, DeepTupleToUnion<ExclusiveGroup<C, K>>>;
                                                                                                                                                                       ~~~~~~~~~~~~~~~~~~~~

node_modules/ganache/dist/ganache.d.ts:7113:141 - error TS2344: Type 'G' does not satisfy the constraint 'unknown[]'.
  Type 'ExclusiveGroup<C, ExclusiveGroupIndex<C>>' is not assignable to type 'unknown[]'.
    Type 'ExclusiveGroups<C>[number]' is not assignable to type 'unknown[]'.

7113 declare type ExclusiveGroupOptionsByGroup<C extends Base.Config, G extends ExclusiveGroup<C>> = PairsToMapping<ExclusiveGroupOptionPairs<C, G>>;
                                                                                                                                                 ~

node_modules/ganache/dist/ganache.d.ts:10699:5 - error TS2416: Property 'hash' in type 'RuntimeTransaction' is not assignable to the same property in base type 'BaseTransaction'.
  Type 'Data | null' is not assignable to type 'Data'.
    Type 'null' is not assignable to type 'Data'.

10699     hash: Data | null;
          ~~~~

Found 7 errors.

Installing the missing dependencies or changing the typeroots doesn't help

gorbak25 commented 2 years ago

The latest version which correctly typechecks is 7.0.0-beta.1

davidmurdoch commented 2 years ago

Thanks, looks like a few things went wrong with the rollup here:

  1. filecoin-related 3rd party types weren't rolled up; we'll be moving the
  2. The packages abstract-leveldown, lru-cache, and seedrandom types were also omitted.

As a workaround you may be able to add "skipLibCheck": true to your tsconfig.json, though this is definitely not ideal, as it will also skip local *.d.ts type checking. You'll still see the all type help in your IDE with this setting enabled, but filecoin types may not be work.

I've added this as a priority 1 issue and slated it for a patch release.

davidmurdoch commented 2 years ago

Related: https://github.com/trufflesuite/ganache/issues/2125