【发布时间】:2019-08-12 18:58:56
【问题描述】:
我有一个名为 service.ts 的文件,它公开了以下代码:
export interface SomeInterface {
keyOne: string;
}
export class TestService<T = SomeInterface> {
property: T;
}
在index.ts 文件中我正在使用该服务:
import { TestService } from './service';
const service = new TestService();
service.property.keyOne
我还创建了index.d.ts 文件,该文件声明了相同的接口SomeInterface 具有更多键:
export interface SomeInterface {
keyTwo: number;
}
问题是service.property 只“知道”keyOne 属性。如何告诉 typescript 合并它们?
【问题讨论】:
标签: typescript