Я создаю собственный класс Typescript в своем проекте Electron, и у меня возникают ошибки при вызове метода.
Класс:
export class RoadHouse extends Object {
public status: string = "ready";
private _output: string = "";
readonly startTime = Date.now();
private running: boolean = false;
constructor(private _message: String = "", private _prompt: String = "") {
//this.setStatus(_message);
}
handleError(message: RoadHouse | string): void {
this.setStatus("Status.Failed");
if (message) {
//
}
}
isRunning(): boolean {
return this.running; // breakpoint set here
}
setStatus(value: string) {
this._output = value;
}
start():void {
this.running = true;
}
stop():void {
this.running = false;
}
}
В main.ts:
var roadHouse:RoadHouse = new RoadHouse("Hello");
console.log("Is running:" + roadHouse.isRunning());
Ошибка:
(узел: 18454) UnhandledPromiseRejectionWarning: TypeError: roadHouse.isRunning не является функцией
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"strictNullChecks":false
}
}
Задача сборки:
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Typescript",
"command": "tsc"
}
]
}
Package.json:
{
"name": "typescript-electron",
"version": "1.0.0",
"description": "Electron and Typescript",
"main": "index.js",
"scripts": {
"test": "start electron ."
},
"devDependencies": {
"electron": "^5.0.3"
}
}