You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { Contract, EventLog, Receipt, Web3 } from "web3";
let web3Initialized: null | Web3 = null;
const getWeb3 = (): Web3 => {
if (!web3Initialized) {
web3Initialized = new Web3(
process.env.REACT_APP_WEB3_PROVIDER_URL as string
);
}
return web3Initialized;
};
and it is giving me this typescript error:
Type 'Web3<{ [key: string]: Web3SubscriptionConstructor<EthExecutionAPI>; }>' is not assignable to type 'Web3<RegisteredSubscription>'.
The types of '_subscriptionManager.subscriptions' are incompatible between these types.
Type 'Map<string, Web3Subscription<any, any, EthExecutionAPI, any>>' is not assignable to type 'Map<string, LogsSubscription | NewPendingTransactionsSubscription | NewHeadsSubscription | SyncingSubscription>'.
Type 'Web3Subscription<any, any, EthExecutionAPI, any>' is not assignable to type 'LogsSubscription | NewPendingTransactionsSubscription | NewHeadsSubscription | SyncingSubscription'.
Type 'Web3Subscription<any, any, EthExecutionAPI, any>' is not assignable to type 'SyncingSubscription'.
Property '_buildSubscriptionParams' is protected but type 'Web3Subscription<EventMap, ArgsType, API, CombinedEventMap>' is not a class derived from 'SyncingSubscription'.ts(2322)
let web3Initialized: Web3<RegisteredSubscription> | null
What am I missing here? Why is the Web3 type not enough?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have this code:
and it is giving me this typescript error:
What am I missing here? Why is the Web3 type not enough?
Beta Was this translation helpful? Give feedback.
All reactions