When using this straightforward Typescript class as a model in an Angular 5 project
export class Category
{
id: string;
label: string;
}
the resulting code does not contain any members
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Category; });
var Category = /** @class */ (function () {
function Category() {
}
return Category;
}());
I am attempting to deserialize JSON data into a list of Category objects using either the json-object-mapper or json-typescript-mapper node modules, but neither is successful due to the absence of generated members in the JS code for the model.
After adding a constructor
constructor() {
this.label = '';
}
it seems to work - which is logical - but it raises the question why there are functional angular models without constructors. Could this be related to some kind of optimization triggered by Angular's Ahead-of-Time Compilation (AOT)?