获得徽章 10
- xdm,有个问题咨询一下,有哪位typescript的大佬帮忙看看啊,琢磨好久了,一直没发解决:
很老的项目用iframe开发,在顶层html里面定义了很多公用方法,在下级的html里面通过top.xxx 的方式调用,我现在想要接入ts希望能够增加vscode的智能提示,现在想要对top的属性进行扩展,但是在ts的lib.dom.d.ts里面已经定义过top了,我这儿再次扩展会提示ts(2403)的错误,有没有大佬帮我看看呀。
想要实现以下代码类似的效果:
interface TopWindow extends Window {
createMP: (key?: string) => CustomPlayer;
}
declare var top: TopWindow | null;
但是最后一行提示错误
Subsequent variable declarations must have the same type. Variable 'top' must be of type 'Window | null', but here has type 'TopWindow | null'.ts(2403)展开41
写了一个 Java多线程专题系列教程(含配套文章) ![[捂脸]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_28.8981538.png)
![[灵光一现]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_25.51e6984.png)