Here is a TypeScript file snippet that I'm working on:
module MyOrganization
{
export module Software
{
export class VersionInfo
{
private _Major: number = 0;
private _Minor: number = 0;
private _Build: number = 0;
private _Revision: number = 0;
public get Major(): number { return (this._Major); }
public get Minor(): number { return (this._Minor); }
public get Build(): number { return (this._Build); }
public get Revision(): number { return (this._Revision); }
constructor(major: number, minor: number, build: number, revision: number)
{
this._Major = major;
this._Minor = minor;
this._Build = build;
this._Revision = revision;
}
public toString(): string
{
return (this._Major.toString() + "." + this._Minor.toString() + "." + this._Build.toString() + "." + this._Revision.toString());
}
private static _LatestVersion: MyOrganization.Software.VersionInfo = new MyOrganization.Software.VersionInfo(1, 0, 0, 0);
public static get LatestVersion(): MyOrganization.Software.VersionInfo { return (MyOrganization.Software.VersionInfo._LatestVersion); }
}
}
}
The LatestVersion
static property is being accessed from an HTML file as shown below:
alert(MyOrganization.Software.VersionInfo.LatestVersion.toString());
Encountering some errors in Google Chrome:
TypeScript:
HTML/JavaScript:
Tried converting the static property to a function and even declaring a version instance but still facing the same issue. Any insights would be helpful!
Generated JavaScript code:
var MyOrganization;
(function (MyOrganization) {
var Software;
(function (Software) {
var VersionInfo = (function () {
function VersionInfo(major, minor, build, revision) {
this._Major = 0;
this._Minor = 0;
this._Build = 0;
this._Revision = 0;
this._Major = major;
this._Minor = minor;
this._Build = build;
this._Revision = revision;
}
Object.defineProperty(VersionInfo.prototype, "Major", {
get: function () { return (this._Major); },
enumerable: true,
configurable: true
});
// Remaining code for properties, functions, and static property here...
}());
Software.VersionInfo = VersionInfo;
})(Software = MyOrganization.Software || (MyOrganization.Software = {}));
})(MyOrganization || (MyOrganization = {}));