Skip to content

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "31337": string[]; }' #3

Discussion options

You must be logged in to vote

You need to create an interface for the code! Typescript will be confused by the typings otherwise:

interface contractAddressesInterface {
    [key: string]: string[]
}
// some code here
    const addresses: contractAddressesInterface = contractAddresses
    const { chainId: chainIdHex, isWeb3Enabled } = useMoralis()
    const chainId: string = parseInt(chainIdHex!).toString()
    const raffleAddress = chainId in addresses ? addresses[chainId][0] : null

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PatrickAlphaC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant