You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Find references even when TypeScript sub-projects not yet open #30823
It seems like with a multiple-tsconfig.json setup, VS Code can't find all references. (Even though technically all of them should be "joined" via a root tsconfig.json that uses project references.)
This is currently known issue in which if the file is not open or declaration maps are not present it cannot find all references in sibling projects. #28261 is wip for this but needs more work before can be merged in since we need to be smart about when to lookup symbol in other projects(as loading projects in most common scenarios is costly and can result in delay when someone does first time find all references)
This blocks us from splitting our code into multiple smaller projects as (consistent!) renaming across the entire codebase is very important to us. We would love to have this feature!
#28261 is wip for this but needs more work before can be merged in since we need to be smart about when to lookup symbol in other projects(as loading projects in most common scenarios is costly and can result in delay when someone does first time find all references)
Personally, I will happily trade off performance for "Find all references" and "Rename symbol" that actually works.
In https://github.com/strongloop/loopback-next, we have configured TypeScript to treat the entire monorepo as a single project, so that we can use "Find all references" and "Rename symbol".
We also don't use declaration maps, therefore cross-project imports are resolved against the original TypeScript sources, not via .d.ts and .d.ts.map files.
This setup works pretty well for us and I am not aware of any performance or memory limitation when working in VS Code. If the performance of #28261 is similar, then I would happily accept it.
Why we want to migrate from our single-project setup to project references when VS Code experience is good now? The problem is that our build times are super slow. We are building each monorepo package independently, because each package has its own outDir, e.g. packages/{name}/dist. Because cross-project imports are resolved against the original TypeScript sources, I suspect that the compiler is repeatedly parsing each TypeScript source file again and again for each top-level package depending on it.
Anyhow. Is there a way how to finish #28261 sooner, possibly without performance optimizations and perhaps behind a new feature flag?
Reacted by rvion, Julius Walther, Biniam Admikew and Luděk
We've recently migrated a very large frontend codebase to sub-projects, and opening files from each before finding references isn't feasible, so we seem to be stuck with grepping for now, or switching to IntelliJ which doesn't seem to rely on TS server to do the references.
Edit: I've just been pointed at #33287 so perhaps a fix is already in progress?
Reacted by Tomas Brambora
Reacted by Sam Cooke, Saxon Landers, Anton Sarmin, Boomer Truong, Wojciech Karaś, Tomek Modrzyński, Declan Vong, Vladimir Katushenok, Tomas Brambora, max-in-bc and 1 more
There is a root tsconfig.json, referencing packages which are a set of composite projects (implementation and tests). In case there is no tsconfig.json with non-empty files in a package, VS Code won't pick up the config for the files in the package.
Another good practice is to have a “solution” tsconfig.json file that simply has references to all of your leaf-node projects and sets files to an empty array (otherwise the solution file will cause double compilation of files). Note that starting with 3.0, it is no longer an error to have an empty files array if you have at least one reference in a tsconfig.json file.
I did all, i created a root tsconfig with references, I set tsconifg in all project with composite: true and still I need to open project to use find references.
I found a hack, I added "files": ["./project1/tsconfig.json", "./project2/tsconfig.json"] to root tsconfig and it seems it force vscode to load all tsconfig and its working very well.
Reacted by MTariqAziz
Reacted by Max Khokhryakov, Victor Glindås, Bruno Heridet and Mark
Activity
mjbvz commentedon Apr 9, 2019
Confirmed with TypeScript 3.5.0-dev.20190407
sheetalkamat commentedon Apr 11, 2019
This is currently known issue in which if the file is not open or declaration maps are not present it cannot find all references in sibling projects. #28261 is wip for this but needs more work before can be merged in since we need to be smart about when to lookup symbol in other projects(as loading projects in most common scenarios is costly and can result in delay when someone does first time find all references)
awerlang commentedon Apr 17, 2019
Ryan Cavanaugh (@RyanCavanaugh) I believe the
Duplicatelabel is a mistake here.hediet commentedon May 28, 2019
This blocks us from splitting our code into multiple smaller projects as (consistent!) renaming across the entire codebase is very important to us. We would love to have this feature!
bajtos commentedon May 31, 2019
Personally, I will happily trade off performance for "Find all references" and "Rename symbol" that actually works.
In https://github.com/strongloop/loopback-next, we have configured TypeScript to treat the entire monorepo as a single project, so that we can use "Find all references" and "Rename symbol".
We also don't use declaration maps, therefore cross-project imports are resolved against the original TypeScript sources, not via
.d.tsand.d.ts.mapfiles.This setup works pretty well for us and I am not aware of any performance or memory limitation when working in VS Code. If the performance of #28261 is similar, then I would happily accept it.
Why we want to migrate from our single-project setup to project references when VS Code experience is good now? The problem is that our build times are super slow. We are building each monorepo package independently, because each package has its own
outDir, e.g.packages/{name}/dist. Because cross-project imports are resolved against the original TypeScript sources, I suspect that the compiler is repeatedly parsing each TypeScript source file again and again for each top-level package depending on it.Anyhow. Is there a way how to finish #28261 sooner, possibly without performance optimizations and perhaps behind a new feature flag?
AnyhowStep commentedon Jun 25, 2019
I currently have a code base that uses composite projects and has 34 sub-projects.
Having to open all 34 sub-projects to "Find all references" is a little tiring =/
alextreppass commentedon Oct 8, 2019
Hi Matt Bierner (@mjbvz) Ryan Cavanaugh (@RyanCavanaugh) apologies in advance for the direct mention. Are there any plans to prioritise this?
We've recently migrated a very large frontend codebase to sub-projects, and opening files from each before finding references isn't feasible, so we seem to be stuck with grepping for now, or switching to IntelliJ which doesn't seem to rely on TS server to do the references.
Edit: I've just been pointed at #33287 so perhaps a fix is already in progress?
pablobirukov commentedon Dec 3, 2019
I have a similar problem in a case implementing scenario described in the project references documentation.
There is a root
tsconfig.json, referencing packages which are a set of composite projects (implementation and tests). In case there is notsconfig.jsonwith non-emptyfilesin a package, VS Code won't pick up the config for the files in the package.https://github.com/pablobirukov/vs-core-project-references
pokey commentedon Mar 2, 2023
For what it's worth, in order to get this to work, we had to add a "solution"
tsconfig.jsonat the root of our repo that references all projects, as recommended in the Typescript handbook:We were able to automate generating this list using meta-updater. See our meta-updater config for more details
aliakbarazizi commentedon Jul 4, 2023
I did all, i created a root
tsconfigwithreferences, I settsconifgin all project withcomposite: trueand still I need to open project to use find references.I found a hack, I added
"files": ["./project1/tsconfig.json", "./project2/tsconfig.json"]to roottsconfigand it seems it force vscode to load alltsconfigand its working very well.docs: explain TypeScript monorepo project references (oraios#1939)