I have created a new class called AppViewModel with a setting property set to 1:
class AppViewModel {
setting: number = 1;
}
export = AppViewModel;
Afterward, I imported the class and instantiated it within another class named OrderEntry:
import AppViewModel = require("appViewModel");
class OrderEntry {
appViewModel = new AppViewModel();
doTest() {
alert(this.appViewModel.setting);
}
}
The code functions correctly. However, I wish to change it to a singleton pattern. So, I updated the export statement as follows:
export var instance = new AppViewModel();
Subsequently, I made a slight adjustment in the consuming class:
import AppViewModel = require("appViewModel");
class OrderEntry {
appViewModel = AppViewModel;
doTest() {
alert(this.appViewModel.setting); //Error Here
}
}
Unfortunately, upon compilation, an error was raised stating that:
Property setting does not exist on type.
How can I resolve this issue?