[英]How can I return a new Type in typescript?
I'm trying to write a d.ts file for a lib which provide a static method extend
to create new type(sub type): 我正在尝试为lib编写一个d.ts文件,该文件提供了extend
创建新类型(子类型)的静态方法:
const SubType = SimpleLib.extend(proto);
const instance = new SubType();
How to write the d.ts file? 如何写d.ts文件?
You could use a generic, something like: 您可以使用通用名称,例如:
declare type Constructor<T> = new (...args: any[]) => T;
function extend<T extends Constructor>(ConstructorToExtend: T) => T;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.