Skip to content

Experiment: auto-import from yet-unimported referenced projects#47690

Closed
andrewbranch wants to merge 10 commits intomicrosoft:mainfrom
andrewbranch:feature/auto-import-project-refs
Closed

Experiment: auto-import from yet-unimported referenced projects#47690
andrewbranch wants to merge 10 commits intomicrosoft:mainfrom
andrewbranch:feature/auto-import-project-refs

Conversation

@andrewbranch
Copy link
Copy Markdown
Member

@andrewbranch andrewbranch commented Feb 2, 2022

Still to-do:

  • Deduplicate files from multiple programs
    • How does this change based on useSourceOfProjectReferenceRedirect? Are there cases where the main program will directly contain .d.ts outputs but the referenced project will show us equivalent .ts inputs?
  • Audit which program should be used to create the module specifier resolution host—it probably should be the main program (look at paths)
  • Test cache invalidation (I think it should be working without changes based on conversation with @amcasey. If it doesn’t, this PR is likely not worth it.)
  • Consider limiting how many total files/projects we put into the ExportInfoMap
  • Test paths module specifier resolution
  • Add perf telemetry

Fixes #39778

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 2, 2022
@andrewbranch
Copy link
Copy Markdown
Member Author

@typescript-bot pack this

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Feb 3, 2022

Heya @andrewbranch, I've started to run the tarball bundle task on this PR at cba8f31. You can monitor the build here.

@andrewbranch
Copy link
Copy Markdown
Member Author

@typescript-bot pack this

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Feb 3, 2022

Heya @andrewbranch, I've started to run the tarball bundle task on this PR at 38def47. You can monitor the build here.

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Feb 3, 2022

Hey @andrewbranch, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/119062/artifacts?artifactName=tgz&fileId=C04E800E60475982E62CAB23E0ED257AC83FFA902C56C9A536757DE329E9D18D02&fileName=/typescript-4.6.0-insiders.20220203.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

Comment thread src/server/project.ts
}

export function getExportInfoMap(importingFile: SourceFile, host: LanguageServiceHost, program: Program, cancellationToken: CancellationToken | undefined): ExportInfoMap {
export function getExportInfoMap(importingFile: SourceFile, host: LanguageServiceHost, program: Program, cancellationToken: CancellationToken | undefined, preferences: UserPreferences): ExportInfoMap {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: I think the cancellationToken is usually the last parameter.

Comment thread src/services/utilities.ts
@andrewbranch
Copy link
Copy Markdown
Member Author

So it turns out that in TS Server, referenced project changes do not trigger any kind of notification / update / reload of the referencing project, so cache invalidation here doesn’t automatically work. Probably the best thing for this feature will be not to add any referenced-project exports into the ExportMapCache. Seeing as there’s been zero feedback since I’ve started working on this, I’m going to table it for now.

@juanrgm
Copy link
Copy Markdown

juanrgm commented Mar 9, 2022

I come from #39778 and I tried this patch but I was not lucky.

None suggestions of referenced projects unless I do the first import.

@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto imports from referenced project not working until already imported once in project

4 participants