镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Find references even when TypeScript sub-projects not yet open #30823

Description

@dcecile

From microsoft/vscode#65102...

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

Here's a minimal repro of my setup: https://github.com/dcecile/typescript-references-test

common/
  message.ts
  tsconfig.json
server/
  hello.ts
  tsconfig.json
client/
  sharedMain.ts
  tsconfig.json
  • Both client and server reference the common project
  • "Find references" fails to find the references to the common function
  • "Rename symbol" also fails to rename the references
  • After loading files from the client and server projects, find references works

Activity

  1. deleted a comment from vscodebot on Apr 9, 2019
  2. removed their assignment
    on Apr 9, 2019
  3. mjbvz commented on Apr 9, 2019

    @mjbvz

    Confirmed with TypeScript 3.5.0-dev.20190407

  4. sheetalkamat commented on Apr 11, 2019

    @sheetalkamat
    Member

    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)

  5. awerlang commented on Apr 17, 2019

    @awerlang

    Ryan Cavanaugh (@RyanCavanaugh) I believe the Duplicate label is a mistake here.

  6. hediet commented on May 28, 2019

    @hediet
    Member

    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!

  7. bajtos commented on May 31, 2019

    @bajtos

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

  8. AnyhowStep commented on Jun 25, 2019

    @AnyhowStep
    Contributor

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

  9. alextreppass commented on Oct 8, 2019

    @alextreppass

    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?

  10. pablobirukov commented on Dec 3, 2019

    @pablobirukov

    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 no tsconfig.json with non-empty files in a package, VS Code won't pick up the config for the files in the package.

    https://github.com/pablobirukov/vs-core-project-references

  11. pokey commented on Mar 2, 2023

    @pokey

    For what it's worth, in order to get this to work, we had to add a "solution" tsconfig.json at the root of our repo that references all projects, as recommended in the Typescript handbook:

    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.

    We were able to automate generating this list using meta-updater. See our meta-updater config for more details

  12. aliakbarazizi commented on Jul 4, 2023

    @aliakbarazizi

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions