so given
class Foo {
}
interface TypeProvider() {
type(): ? ;
}
class Bar implements TypeProvider {
type(): ? {
return (Foo);
}
}
class Baz implements TypeProvider {
type(): ? {
return (Bar);
}
}
Foo
is a class but if I'm returning a class from a method, what type do I assign the method signature?
as an aside is return (Foo)
and return Foo
the same thing? if they're different I'm not certain I don't want the latter.
It should be the Foo
constructor:
class Bar {
type(): { new(): Foo } {
return (Foo);
}
}
Or:
interface FooConstructor {
new(): Foo;
}
class Bar {
type(): FooConstructor {
return (Foo);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.