-
Notifications
You must be signed in to change notification settings - Fork 640
Project references in a program #1078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
36a4391
to
41e38d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
SyncMap
for extended config caching and updateperformCompilation
accordingly. - 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
computeCommonSourceDirectoryOfFilenames
lack 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 {
@@ -115,8 +116,8 @@ func executeCommandLineWorker(sys System, cb cbType, commandLine *tsoptions.Pars | |||
|
|||
if configFileName != "" { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually do this concurrently enough to require a SyncMap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. which is why i didnt make it address but i can if thats more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: