I just started to learn typescript. I was asked to transpile a java library with JSweet to embed it in an Angular project. The java library contain only pure logic and do not depends from other library. The transpilaton go smooth and the result are a series of .ts files in the form:
namespace com.test {
export lib_class_name {
... transplied content ...
}
}
The problem arise when I try to reference these classes from an angular component. Example:
import { Component, OnInit } from "@angular/core";
@Component({
selector: "app-dashboard",
templateUrl: "./dashboard.component.html",
})
export class DashboardComponent implements OnInit {
constructor() {
let tmp = new com.test.lib_class_name()
}
ngOnInit() {}
}
The code compile correctly but I receive a runtime error:
ERROR Error: Uncaught (in promise): ReferenceError: com is not defined
ReferenceError: com is not defined
at new DashboardComponent (dashboard.component.ts:10)
I've tried to reference the class in several way, based on similar error solving tip I found on the internet, but the result is always the same.
Why this happen and how could I resolve it?
Thank you
I solved: I need to enable module support in JSweet transplier options. Now JSweet generate class in the form:
witch are compatible with angular module.