How to use Typescript, to solve the problem that two classes of two different files need to refer to each other for type checking

problem description

it is found that it exists when looking at the VSCode source code.
Class A will create Class B ,
Class B method needs to use Class A instance as a parameter,
ts needs to define the type when declaring parameters or variables,
thus constitutes the problem of mutual reference.

but VSCode solves this problem by packaging, using absolute paths when importing.
but a new problem arises. The editor cannot trace, so there is no code hint

.

so is there any way to solve both cross-reference and editor prompts ?

example

this example is not appropriate, you can implement the same function through other structures to avoid this problem, but the main purpose here is to illustrate how I want to quote it.

/* parent.ts */
import { Child } from "./child"

export class Parent {
    firstName: string
    lastName: string
    child: Child
    constructor(firstName: string, lastName: string, childfirstName: string) {
        this.firstName = firstName
        this.lastName = lastName
        this.child = new Child(childfirstName)
    }
    getChildName() {
        return this.child(this)
    }
}
/* child.ts */
import { Parent } from "./parent"

export class Child {
    firstName: string
    constructor(firstName: string) {
        this.firstName = firstName
    }
    getName(parent: Parent) { // Parent
        return this.firstName + " " + parent.lastName
    }
}
/* test.ts */
import { Parent } from "./parent"

const parent = new Parent("Jonathan", "Joestar", "George")
console.log(parent.getChildName()) // George Joestar
Nov.01,2021

generally understand. It is recommended to refer to the parent class instance in the constructor in the subclass, and the rest of the operations should be performed on the instance, which should solve the problem

.
Menu