I am converting a class to a type, but I want to convert that type back to a class. Say I have this class:
export namespace Entities{
export namespace Bar{
export class Foo {
}
}
}
and then I have a reference to the type:
type F = Entities.Bar.Foo;
is there a way to convert F back to a value instead a type?
something like:
const V = valueof F;
where V would just be a reference to the Foo class.
(I guess what is weird is that a class in TypeScript is both a type and a value/expression).
The reason I ask is because I have this scenario:
type F = Entities.Bar.Foo;
const x = doSomethingWithClass(Entities.Bar.Foo);
but I would like to convert it to this scenario:
type F = Entities.Bar.Foo;
doSomethingWithClass(F);
but that doesn't compile, I get:
Can't use type F as an expression.
alternatively, if someone knows how to return a type from a function, that might be good enough:
type F = doSomethingWithClass(Entities.Bar.Foo);