I am evaluating TypeScript to see if it could save time in development for my requirements. Lets say I define simple classes to get and set hidden fields with the main purpose of being generic and working with MVC models.
class BaseObject {
_Name: string;
constructor(public name) { this._Name = name; }
}
interface BaseForm {
SaveFields(): void;
GetFields(): void;
ToQueryString(): string;
ToJsonString(): string;
}
class BaseReportForm extends BaseObject implements BaseForm {
constructor(name) { super(name); }
public PageNumber: number;
public AllowPaging: bool;
public ExportLink: string;
...
SaveFields() {//WRITE HIDDEN FIELDS TO FORM }
GetFields() { //GET HIDDEN FIELDS FROM FORM}
ToQueryString() { return "Hidden Fields To Query String"; }
ToJsonString() { return "Hidden Fields To Json"; }
}
This all works great, however, I am not seeing anything that would allow me to work with @Models. It would be nice to be able to have the ability to magically do the following:
var ReportForm=new ReportForm(@Model.Report);
I am aware that to achieve this functionality there would have to be another translation layer of translations. Are there any tools that would help if it turns out to be a time saver? Similar to an ORM mapper or auto mapper but would work with JS or TypeScript?