繁体   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