I'm getting some data from a server and then parsing it into TypeScript classes. I'm trying use some inheritance - every class needs to be able to report its type. Here's how that works:
This is the base class
import { PageElementType } from './page-element-type'
export class PageElement {
    pageElementType: PageElementType;
    constructor(aPageElementType: PageElementType) { 
        this.pageElementType = aPageElementType; 
    }
}
This is a derived class
import { PageElement } from './page-element.model'
import { PageElementType } from './page-element-type'
export class Metadata extends PageElement {
    id: number;
    body: string;
    constructor(){
        super(PageElementType.metadata);
    }
}
Here's the service function I call to parse the data
getExam(){
    let exam = this.http.get('http://orangeberry.hopto.org/api/Exam/1')
    .map((response:Response) => <Exam>response.json())
    .do(data => console.log(data));
    return exam;
}
Seems like I'm getting some sort of plain objects. I want meaningful, functional objects that actually follow the class definition. What's the simplest and most straight-forward way of achieving this for my case?
 
     
    