簡體   English   中英

什么類型代表打字稿中的類型?

[英]What type represents a type in typescript?

所以給

class Foo {
}

interface TypeProvider() {
    type(): ? ;
}

class Bar implements TypeProvider {
    type(): ? {
        return (Foo);
    }
}

class Baz implements TypeProvider {
    type(): ? {
        return (Bar);
    }
}

Foo是一個類,但是如果我要從方法返回一個類,我應該為方法分配什么類型的簽名?

順帶一提的是return (Foo)return Foo是同一件事嗎? 如果他們不同,我不確定我不要后者。

應該是Foo構造函數:

class Bar {
    type(): { new(): Foo } {
        return (Foo);
    }
}

要么:

interface FooConstructor {
    new(): Foo;
}

class Bar {
    type(): FooConstructor {
        return (Foo);
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM