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

Typescript Find All Reference does not work in monorepo #56268

Closed
jaysoo opened this issue Oct 26, 2023 · 4 comments
Closed

Typescript Find All Reference does not work in monorepo #56268

jaysoo opened this issue Oct 26, 2023 · 4 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@jaysoo
Copy link

jaysoo commented Oct 26, 2023

Does this issue occur when all extensions are disabled?:No

Version: 1.83.1 (Universal)
Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc
Date: 2023-10-10T23:46:55.789Z
Electron: 25.8.4
ElectronBuildId: 24154031
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 22.6.0

Steps to Reproduce:

  1. Git clone the Nx monorepo
    git clone https://github.com/nrwl/nx.git
    cd nx
    pnpm install
  2. Open vscode code .
  3. Open file packages/devkit/src/utils/async-iterable/create-async-iterable.ts
  4. Find all references of createAsyncIterable

Expected:
All references are found (should be 17 invocations)

Actual:
No usages found (only reference is the declaration)

Screenshot 2023-10-26 at 11 03 16 AM

Related issues

#30823, microsoft/vscode#65102

@mjbvz mjbvz transferred this issue from microsoft/vscode Oct 30, 2023
@mjbvz mjbvz removed their assignment Oct 30, 2023
@RyanCavanaugh
Copy link
Member

This seems working as intended. You have a "solution" tsconfig at packages/devkit/tsconfig.json, so as far as TS can tell, that's the entire "world of analysis" available to it (in other words, this appears to be you trying to make sure nothing else loads, and nothing else loads). TS doesn't communicate with VS Code about what the workspace root is - these are kind of supposed to be separate concepts - so there's nothing that tells TS that it ought to go looking into packages/js for example. It appears to be "not your code".

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Oct 30, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2023
@jaysoo
Copy link
Author

jaysoo commented Nov 21, 2023

So the only workaround is to not use solution tsconfig? Is there anything else that can be done tell VS Code to follow the paths from root tsconfig file?

@svallory
Copy link

svallory commented Apr 4, 2024

it's been a while @jaysoo , but just in case...

And for others stumbling upon this issue...

What @RyanCavanaugh meant by "solution tsconfig" is that the tsconfig file inside dev kit defines all that is need to be compiled. It's the entire thing and not, for example, part of a larger solution, a composite tsconfig which references or is referenced by other tsconfigs.

VSCode asks TS about project information, never the other way around. And When typescript compiles the devkit project, it will follow the tsconfig.json, and only look at the files specified there and in referenced projects.

Since from the tsconfig the TSC does not know of the existence of other projects, no reference will be found.

Your options are either to reconfigure the tsconfig of the projects to use project references, or to create a separate tsconfig.vscode.json which includes code from all projects and tell vscode to use it instead via workspace settings

(actually, maybe you'll have to create a tsconfig.build.json for building and optimize the original just for the IDE)

I suggest you start using project references

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

5 participants