Repository navigation
Project references in a program - #1078
Conversation
36a4391 to
41e38d3
Compare
41e38d3 to
e97ee3c
Compare
There was a problem hiding this comment.
Pull Request Overview
Adds support for parsing and applying project reference configurations, enabling conditional redirection between source files and generated declaration outputs.
- Replace a simple map with a thread-safe
SyncMapfor extended config caching and updateperformCompilationaccordingly. - Introduce core helpers to resolve project reference paths and compute common source directories.
- Extend the file loader, program, and checker to generate parse tasks for project references and redirect module resolution based on options.
Reviewed Changes
Copilot reviewed 56 out of 56 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/execute/tsc.go | Swap out map-based cache for SyncMap and update performCompilation API |
| internal/core/projectreference.go | Add functions to resolve project reference config file paths |
| internal/core/commonsourcedirectory.go | Implement logic to compute common source directory for a set of files |
| internal/compiler/fileloader.go | Hook in project reference parse tasks and initialize the reference mapper |
| internal/checker/utilities.go | Extend SkipTypeChecking to skip files originating from project references |
Comments suppressed due to low confidence (4)
internal/core/commonsourcedirectory.go:1
- [nitpick] New functions like
computeCommonSourceDirectoryOfFilenameslack unit tests; consider adding tests for various path layouts and edge cases.
package core
internal/core/projectreference.go:11
- [nitpick] Add unit tests for
ResolveProjectReferencePath(and its helper) to verify correct handling of JSON vs directory inputs.
func ResolveProjectReferencePath(ref *ProjectReference) string {
internal/core/commonsourcedirectory.go:20
- The helper 'min' is undefined; compute the minimum explicitly (e.g.,
if a < b { n = a } else { n = b }) or import a valid utility.
n := min(len(commonPathComponents), len(sourcePathComponents))
internal/core/commonsourcedirectory.go:21
- Cannot range over an integer; replace with a classic for loop:
for i := 0; i < n; i++ { ... }.
for i := range n {
| configStart := sys.Now() | ||
| extendedConfigCache := map[tspath.Path]*tsoptions.ExtendedConfigCacheEntry{} | ||
| configParseResult, errors := tsoptions.GetParsedCommandLineOfConfigFile(configFileName, compilerOptionsFromCommandLine, sys, extendedConfigCache) | ||
| extendedConfigCache := collections.SyncMap[tspath.Path, *tsoptions.ExtendedConfigCacheEntry]{} |
There was a problem hiding this comment.
Do we actually do this concurrently enough to require a SyncMap?
There was a problem hiding this comment.
we will with project references - many projects could be using same extends cache and parsing at the same time.
| return w.collectWorker(loader, tasks, iterate, collections.Set[K]{}) | ||
| } | ||
|
|
||
| func (w *fileLoaderWorker[K]) collectWorker(loader *fileLoader, tasks []K, iterate func(K, []tspath.Path), seen collections.Set[K]) []tspath.Path { |
There was a problem hiding this comment.
I am suspicious of collections.Set[K] just because it's an auto-initializing struct containing a map, which means passing it by value will cause separate call chains to not actually share that underlying map. Perhaps a pointer is warranted here?
There was a problem hiding this comment.
I guess this probably works out because the first thing it does is add the task, so any recursive calls will have preinitialized the map.
There was a problem hiding this comment.
Yeah. which is why i didnt make it address but i can if thats more clear
There was a problem hiding this comment.
I guess it's fine for now. I'll probably noCopy these in the future to make the bug impossible, but there's technically no bug here.
Adds support to parse project reference configs, redirect to either output or source depending on options
TODOs as next PR: