0

We have a large Typescript project and we are trying to improve incremental compilation time, which is sometimes dominating development time. For many files, if we follow all import statements, we would reach most files of the project, so incremental compilation can be very slow. We are working on reducing the connectivity in this graph, but we have also noticed that for some changes we make in a Typescript file, importing files are not recompiled with --incremental or in watch mode.

For example, changing a method body (but not its signature) in a class does not cause recompilation of files that import that class. In addition, adding (soft and hard) private fields to a class, or file local declarations, does not seem to cause recompilation of importers.

However, we have noticed that, when using the mixin pattern (https://www.typescriptlang.org/docs/handbook/mixins.html), any change to the mixin class causes recompilation of all importers, even adding hard private fields. It seems that using import/export type does not make any difference with regard to dependencies, how ever we have found no relevant documentation.

Is there a formal documentation of what constitutes a dependency for the purpose if incremental compilation? Is this dependency graph obtainable from the compiler (or the incremental compilation output)? More practically, is there a way to use mixins without creating compilation dependencies on private fields and method implementations? We have only been able to resolve this by introducing interfaces for all involved classes, but this is quite cumbersome and causes its own problems. It seems not possible to divide the project to sub-projects and use project references as we would get circular dependencies in any such division.

For the purpose of strictNull checking, we are trying to introduce them gradually to our code as recommended, but adding one file to the list of checked files also adds all the files it transitively imports (or so it seems). Is there a formal documentation of the dependency relation used here? Is it identical with the one for incremental compilation?

0 Answers0