2017-05-27 61 views
0

我試圖寫一個lib它提供了一個靜態方法extend創造新的類型(子類型)的d.ts文件:如何返回打字稿中的新類型?

const SubType = SimpleLib.extend(proto); 
const instance = new SubType(); 

怎麼寫d.ts文件?

+0

訪問:https://stackoverflow.com/questions/13613524/get-an-objects-class-name-at-runtime-in-typescript – kjppster

回答

0

你可以使用一個通用的,是這樣的:

declare type Constructor<T> = new (...args: any[]) => T; 

function extend<T extends Constructor>(ConstructorToExtend: T) => T;