我有以下代码:
import bre from "@nomiclabs/buidler"; async function main(): Promise<bre.ethers.Contract> { const Greeter = await bre.ethers.getContractFactory("Greeter"); // bre.ethers.Contract exists here }
为什么TypeScript不编译它,如果布雷以太合同存在?如果写在函数内部,我可以将其用作类型。
我从Typescript操场得到了以下警告:
interface T { A: { B: { test: string } } } var a = new Promise<T.A.B>((res, rej) => { res({test: "hello"}); });
无法访问“T.A”,因为“T”是类型,但不是命名空间。是否要用“T[“A”]”检索“T”中属性“A”的类型?
interface T { A: { B: { test: string } } } var a = new Promise<T["A"]["B"]>((res, rej) => { res({test: "hello"}); });
Playground Link