Meaning you cannot use something like this?
class Helpers
{
static ObjectAs(val: any): T {
if (!(val instanceof T)) {
return
The type system is wholly erased. You can see this in the generated code for any generic function.
That said, for classes, there's still some runtime information left. You could write this:
class A { }
class B { }
function As<T>(n: any, type: { new(...args: any[]): T }): T {
if(n instanceof type) {
return n;
} else {
return null;
}
}
var x = new A();
var y = new B();
console.log(As(x, A));
console.log(As(x, B));