I am new to using TypeScript. I have a project with Knockout TS, and after compiling it (using the Intellij plugin to automatically compile ts to js),
this is my sample.ts file:
import * as ko from "knockout"; ko;
class HelloViewModel {
language: KnockoutObservable<string>
framework: KnockoutObservable<string>
constructor(language: string, framework: string) {
this.language = ko.observable(language);
this.framework = ko.observable(framework);
}
}
ko.applyBindings(new HelloViewModel("TypeScript", "Knockout"));
and here is my sample.js file:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ko = require("knockout");
ko;
var HelloViewModel = /** @class */ (function () {
function HelloViewModel(language, framework) {
this.language = ko.observable(language);
this.framework = ko.observable(framework);
}
return HelloViewModel;
}());
ko.applyBindings(new HelloViewModel("TypeScript", "Knockout"));
However, when running it on the browser, an error message pops up saying: Uncaught ReferenceError: exports is not defined at sample.js:2
I have been trying to find a solution for this issue but haven't had any luck so far. If you have any tips or solutions, please share them.
You can also check out my project here: https://github.com/hoangdangduy/StreamingVideoWeb