我要为window对象上添加一个属性:videoInstance
,将它的类型设置为index.ts
中导出的Video
,按照网上的方法通过import()的方式导入,也尝试了/// <reference path='./index.ts'/>
但是并没有效果。正确应该怎么写呢?
index.d.ts
declare type MapType = '3D' | 'GIS' | 'VIG';
// type Video = import('./../components/Video/index').Video
interface Window {
videoInstance: ;
}
declare var videoInstance: Window['videoInstance'];
index.ts
class Video {
public show(props: Props) {
// TODO
}
public close() {
// TODO
};
};
export default Video
.d.ts中如果通过
import xxx from '...'
导入一个模块,会导致.d.ts
变成一个普通的js、ts
模块,应该通过import(‘xxx.ts’)
的方式导入,例如问题中的index.ts中默认导出了Video类,想要在
.d.ts
中导入Video
作为一个类型应该写为:type Video = import('index.ts').default