元素隐式具有 'any' 类型,因为 'any' 类型的表达式不能用于索引 nodejs 和 solidity 中的类型
Element implicitly has an 'any' type because expression of type 'any' can't be used to index type in nodejs and solidity
我需要在合同中设置网络。我使用 nodejs 并输入脚本。
我写了这段代码:
let networkId: any = await global.web3.eth.net.getId();
let tetherData = await Tether.networks[networkId];
但它向我显示此错误:
Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.ts(7053)
现在我该如何解决这个问题?
这是json我合同的文件
let networkId: number = await global.web3.eth.net.getId();
let tetherData = await Tether.networks[(networkId as number)];
为什么:
getId(callback?: (error: Error, id: number) => void): Promise<number>;
^^^^^^
我需要在合同中设置网络。我使用 nodejs 并输入脚本。
我写了这段代码:
let networkId: any = await global.web3.eth.net.getId();
let tetherData = await Tether.networks[networkId];
但它向我显示此错误:
Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.ts(7053)
现在我该如何解决这个问题?
这是json我合同的文件
let networkId: number = await global.web3.eth.net.getId();
let tetherData = await Tether.networks[(networkId as number)];
为什么:
getId(callback?: (error: Error, id: number) => void): Promise<number>;
^^^^^^