Description
IMPORTANT: This depends on an unimplemented feature request in TypeScript: --isolatedDeclarations
microsoft/TypeScript#47947
What is the current behavior?
Currently, type-checking a tree of targets like app <-- counter <-- textutils/splitter
requires that they are run in serial, because the results of type-checking a library are needed by all transitive dependents as inputs to their type-check action.
Quoting from the --isolatedDeclarations
proposal:
To compile, we need to first compile textutils/splitter, wait for that to complete, e.g. 5s, then compile counter, wait e.g. 3s, then compile app (6s). Total compilation wall time is |app| + |counter| + |textutils/splitter|, in our example 5s + 3s + 6s = 16 seconds.
Describe the feature
Again, quoting from the --isolatedDeclarations
proposal:
Now assume we could produce .d.ts files without requiring transitive inputs. That'd mean we could, in parallel, produce the .d.ts files for textutils/splitter, counter (and app, though we don't need that). After that, we could, in parallel, type check and compile textutils/splitter, counter, and app. Assuming sufficient available parallelism (which seems reasonable, given how common multicore CPUs are), total compilation wall time is the maximum time to extract .d.ts files, plus the time for the slowest compile. Assuming .d.ts extraction is purely syntactical, i.e. does not need type checking nor symbol resolution, it shouldn't add more overhead than a few hundred ms. Under these assumptions, the wall time to wait for the project to compile would be 500 ms + 6s = 6.5 seconds, i.e. more than a x2 speedup.
When the --isolatedDeclarations
feature is available in some version of TypeScript, then rules_ts should support it with an action graph like the one implied there.