Let's say I have two files, A.js and B.js. Both need references to each other like this.
A.js
import { B } from "b"
export class A {
constructor(public name: string) {}
}
let b = new B();
b.print(new A("This is a random name"));
B.js
import { A } from "a"
export class B {
print(a: A) {
console.log(a.name);
}
}
The example above will create a circular reference which currently does not work in the JavaScript runtime I'm using. The file B.js really only need the type information, not the actual export object). I want the type from A.js to get static type checking. Is this possible?
class Ato a different file, and import them both when you want to dob.print(...)?Aneeds to referenceB. Move the rest of the code elsewhere.