class base {
a: number;
b: number;
}
class child extends base {
c: number;
}
let obj: child = { a: 4, b: 5, c: 6 };
let test: base = obj as base;
console.log(test);
Will output { a: 4, b: 5, c: 6 }
How to output { a: 4, b: 5 } ?
Types do not change how your program works. They only exist in during "compilation".
To change the output you will have to make your code remove the property.
See
So, to output only a
and b
you have to call a code to delete c
delete obj.c;