-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
TypeScript: aggregate errors for file from all projects #20185
Comments
Related to #20184 as both involve the same file that is part of multiple |
Another issue I just hit because of this: "find references" will not show all actual references. Perhaps the errors and references should be grouped by the |
not sure i understand this comment, can you elaborate? |
When I have a file that is used in multiple TS projects, "find references" will not show references across all of those TS projects. Steps to reproduce:
Edit: after further testing, I've found the same occurs if If I navigate to the shared file from a file in one of the other projects, TS/VSCode will only show references applicable to the project of the previously viewed file. |
@mhegazy Are there any updates on this? I am just starting another project which has similar requirements: two TS projects with their own dependency graph and some shared dependencies (e.g. Let me know if you want any more information about the problem. |
That sounds like a bug. I have not had a chance to invistigate though. |
This issue is really bothering me so here are some clearer steps to reproduce. We have two TS projects,
// project1/index.ts
import { foo } from "../shared/index"; // project1/tsconfig.json
{
"files": [
"./index.ts"
]
} // project2/index.ts
import { foo } from "../shared/index"; // project2/tsconfig.json
{
"files": [
"./index.ts"
]
} // shared/index.ts
export const foo = 1; Finding references on a shared symbol in one of the TS projects only shows references in the TS project of the selected file—VSCode/TypeScript does not aggregate the references of all TS projects that apply to the current file. E.g. missing references in Finding references on a symbol in the shared file shows no references. E.g. missing references in … unless VSCode/TypeScript has also opened a file from one of the other TS projects, in which case only references from that TS project will be shown. E.g. missing references in I am only demonstrating the behaviour of references, but the same behaviour extends to error reporting, refactors like renaming, etc. Ideally VSCode/TypeScript would aggregate all TS projects for the current file. Alternatively, is there a better way to structure the project? Potentially related issues: |
When you open shared.ts the context matters, since its not directly referenced in any of the tsconfig file in its directory hierarchy ... tsserver will have the information of project/projects it was opened/used in earlier. If project1 is open, there is no way to know that it would also be referenced in project2 unless it is open and hence the behaviour you see. For any file we only look in its hierarchy for the tsconfig file. |
This is not bug @mhegazy . unless the project is open there is no really default config project for shared file to be able to deduce its being referenced in those other projects whose tsconfig's are not even in directory chain. |
this is about having the file in multiple contexts. we already do something similar for find all refs for instance where we repeat the process for every containing project. |
@sheetalkamat That explains the current behaviour. @mhegazy Do you think there's anything TypeScript/VSCode could offer to make the user experience better here? It's quite common to have multiple TS projects with overlapping dependency graphs, e.g. I think it's clear that this is the ideal/intuitive user experience, but what are the challenges involved with getting there? |
Could TypeScript/VSCode not check whether a file appears in all TS projects (in the root folder)? I presume this has performance challenges though? |
yes. the server only knows about open files/projects. a file can be referenced from any where on disk, and it is not manageable to search for possible incoming references everywhere. I think a better solution for your scenario is #3469 |
How do you imagine this (composite projects?) helping the situation? I guess we would have two TS projects, |
you would have a tsconfig.josn at the root that is empty, but has a set of project references to both projects, the server would load that one if it happened to be on the root of your project directory (the folder you used to open vscode |
That makes sense! In that case, we can close this in favour of #3469 |
Fixed by #3469 |
Re. #20185 (comment)
This idea works with |
From @OliverJAsh on September 30, 2017 16:20
I have a project with three folders, two of which are TS projects and the third of which is shared between them:
tsconfig.json
)tsconfig.json
)Both "browser" and "service-worker" depend on "shared".
However, when I open a file in "shared", I only see errors related to one of the
tsconfig.json
s—usually this will be thetsconfig.json
used for the file I navigated from previously.It would be great if VSCode could aggregate all errors for the current file for all matching TS projects.
Copied from original issue: microsoft/vscode#35432
The text was updated successfully, but these errors were encountered: