Skip to content

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

Closed
Andrew Branch (andrewbranch) wants to merge 10 commits into
microsoft:mainfrom
andrewbranch:feature/auto-import-project-refs
Closed

Experiment: auto-import from yet-unimported referenced projects#47690
Andrew Branch (andrewbranch) wants to merge 10 commits into
microsoft:mainfrom
andrewbranch:feature/auto-import-project-refs

Conversation

@andrewbranch

@andrewbranch Andrew Branch (andrewbranch) commented Feb 2, 2022

Copy link
Copy Markdown
Member

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 Andrew Casey (@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

@andrewbranch

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 3, 2022

Copy link
Copy Markdown
Contributor

Heya Andrew Branch (@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 (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 3, 2022

Copy link
Copy Markdown
Contributor

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

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 3, 2022

Copy link
Copy Markdown
Contributor

Hey Andrew Branch (@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".;

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

Juanra GM (juanrgm) commented Mar 9, 2022

Copy link
Copy Markdown

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 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