I have the following typescript code labeled A below, in VS 2015 Update 3 but it produces code labeled B below. The problem is the source has fields but the output has none. Please help.
A.
"use strict";
export class RoleViewModel {
public Id: number;
public Name: string;
public Description: string;
public IsEnabled: boolean;
public ResourceCustomizationId: number;
}
B.
"use strict";
export class RoleViewModel {
}
//# sourceMappingURL=role.js.map
Javascript doesn't know about fields declaration and TypeScript will remove all fields that are not assigned in your class or referenced by any method.
The workaround you have is to set a default value to those fields like this:
export class RoleViewModel {
public Id: number = 0;
public Name: string = "";
public Description: string = "";
public IsEnabled: boolean = false;
public ResourceCustomizationId: number = 0;
}
And it will generate the following code:
export class RoleViewModel {
constructor() {
this.Id = 0;
this.Name = "";
this.Description = "";
this.IsEnabled = false;
this.ResourceCustomizationId = 0;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With