In UML, we know there is a term "dependency".
We are eager to know what the definition of dependency is. For example:
class B {}
class A {
constructor(b: B){...}
}
b
is not inside A
. In this case, does it mean that A
does not depend on B
?Person.ts
imports Animal.ts
. Then is Person.ts
dependent on Animal.ts
?===
There is an relation answer, but I don't think it's a good explanation.
Dependency is the most general relationship between two elements.
You can think of the dependency relationship like this: A
depends on B
is changes to B
might necessitate changes to A
.
When talking about TypeScript, the first thing that indicates a dependency is the import
keyword (note that sometimes there is an implicit import).
Looking at your cases:
A
depends on B
because changes in B
might necessitate changes to A
.Person.ts
depends on Animal.ts
because changes in Animal.ts
might necessitate changes to Person.ts
.P.S. For example, if there are association, aggregation, composition, generalization, or realization relationship between A and B, then A depends on B because changes to B might necessitate changes to A.