Skip to content
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

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

Conversation

andrewbranch
Copy link
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
Member Author

@typescript-bot pack this

@typescript-bot
Copy link
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
Member Author

@typescript-bot pack this

@typescript-bot
Copy link
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
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/pr-build@4.6.0-pr-47690-4".;

src/server/project.ts Show resolved Hide resolved
@@ -360,7 +394,7 @@ namespace 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
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.

src/services/utilities.ts Show resolved Hide resolved
@andrewbranch
Copy link
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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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