Skip to content

Watch type reference locations too and handle auto type refs #1239

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

Merged
merged 1 commit into from
Jun 19, 2025

Conversation

sheetalkamat
Copy link
Member

Pulling out watching type refs and handling auto type refs change from #1217

@sheetalkamat sheetalkamat marked this pull request as ready for review June 19, 2025 20:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances module resolution watching by also tracking type reference lookups and adds support for automatically resolving type directives during parsing.

  • Replace getModuleResolutionWatchGlobs with updateModuleResolutionWatches to unify watching of both module and type reference paths.
  • Introduce the generic extractLookups helper to collect failed and affecting lookup locations.
  • Add automatic type directive parsing by marking special parse tasks and resolving them in the file loader.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/project/project.go Refactor watcher setup to use updateModuleResolutionWatches and new extractLookups
internal/module/types.go Add GetLookupLocations methods for resolved modules and type reference directives
internal/compiler/program.go Expose GetResolvedTypeReferenceDirectives to retrieve type directive resolutions
internal/compiler/parsetask.go Introduce isForAutomaticTypeDirective flag and loadAutomaticTypeDirectives logic
internal/compiler/fileloader.go Wire up automatic type directive resolution into parsing and task collection
Comments suppressed due to low confidence (6)

internal/project/project.go:350

  • New function updateModuleResolutionWatches lacks associated unit tests to verify watch behavior for both module and type reference lookup updates; consider adding tests to cover different resolution scenarios.
func (p *Project) updateModuleResolutionWatches(ctx context.Context) {

internal/module/types.go:84

  • Exported method GetLookupLocations should have a doc comment explaining it returns the lookup locations for failed and affecting module paths.
func (r *ResolvedModule) GetLookupLocations() *LookupLocations {

internal/compiler/program.go:816

  • This method exposes the internal map directly, allowing external mutation of program state; consider returning a copy or read-only view to preserve encapsulation.
func (p *Program) GetResolvedTypeReferenceDirectives() map[tspath.Path]module.ModeAwareCache[*module.ResolvedTypeReferenceDirective] {

internal/compiler/parsetask.go:19

  • [nitpick] Field isForAutomaticTypeDirective is verbose and its purpose may not be immediately clear; consider a name like skipStandardLoad or autoTypeDirectiveFlag for clarity.
	isForAutomaticTypeDirective bool

internal/compiler/fileloader.go:200

  • resolveAutomaticTypeDirectives introduces new parsing logic but lacks dedicated tests to verify behavior when no directives or multiple directives are present; adding unit tests would improve confidence.
func (p *fileLoader) resolveAutomaticTypeDirectives(containingFileName string) (

internal/project/project.go:543

  • [nitpick] Using context.TODO() here may obscure cancellation or deadlines; consider propagating a proper context or using context.Background() explicitly to clarify intent.
		p.updateModuleResolutionWatches(context.TODO())

@sheetalkamat sheetalkamat added this pull request to the merge queue Jun 19, 2025
Merged via the queue into main with commit 264347f Jun 19, 2025
22 checks passed
@sheetalkamat sheetalkamat deleted the typeRefs branch June 19, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants