I have a typescript file like so:
class FieldModel
{
constructor() { console.log('test'); }
}
When I instantiate FieldModel
using new FieldModel()
from ordinary javascript or browser console, it works perfectly as tsc
generates the following javascript:
var FieldModel = /** @class */ (function () {
function FieldModel() {
console.log('test');
}
return FieldModel;
}());
But when the above ts file has an import declaration like below, then I can't instantiate FieldModel as I get the error that class is not defined.
import {Subject} from "rxjs";
class FieldModel
{
constructor() {
console.log('test');
new Subject();
}
}
tsc
generates below javascript for the above code:
define("Path/to/the/typescript/file/without/extension", ["require", "exports", "rxjs"], function (require, exports, rxjs_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FieldModel = /** @class */ (function () {
function FieldModel() {
console.log('test');
new rxjs_1.Subject();
}
return FieldModel;
}());
});
I just want to be able to access the FieldModel
class from a legacy javascript code (or browser console for that matter) but I have no idea how to get around this define generated from the second snippet.