在我的nextjs项目中,我有以下代码:
const go = new global.Go()
CCD_ 1是通过wasm定义的。
当我运行tsc
命令时,我得到以下错误:
error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
因此,我创建了文件types/global.d.ts
,并添加了以下行:
export declare global {
function Go(): unknown
}
但现在我得到了这个错误:
error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.
我该如何解决这个问题?
如错误消息所示;给它一个构造签名
export declare global {
const Go: new () => Go
}