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

bug: go to definition is not working #1124

Open
dominikjasek opened this issue Jul 24, 2024 · 11 comments
Open

bug: go to definition is not working #1124

dominikjasek opened this issue Jul 24, 2024 · 11 comments
Labels
blocked bug Something isn't working upstream problem is on an upstream package

Comments

@dominikjasek
Copy link

dominikjasek commented Jul 24, 2024

Provide environment information

System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Pro
Memory: 57.50 MB / 32.00 GB
Shell: 5.9 - /bin/zsh

Binaries:
Node: 20.11.1 - ~/.nodenv/versions/20.11.1/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.2.4 - ~/.nodenv/versions/20.11.1/bin/npm
pnpm: 9.6.0 - /opt/homebrew/bin/pnpm
bun: 1.0.0 - ~/.bun/bin/bun
Watchman: 2024.05.06.00 - /opt/homebrew/bin/watchman

Describe the bug

I cloned the repository, trying to navigate through code. I am unable to go to definition (as well as see usages) of procedure in both VSCode and RubyMine (IntelliJ). I have another project with simple Next.js tRPC without monorepo and it's working fine there. Any ideas?

rubymine.mp4
vscode.mp4

Link to reproduction

none, just clone template repo

To reproduce

Clone repo, try to navigate to definition

@juliusmarminge
Copy link
Member

You need to run a build first so the declaration files are emitted.

We use declaration files to keep the tsc performance up as the project scales, a downside with that is that you lose "live types"

@dominikjasek
Copy link
Author

dominikjasek commented Jul 24, 2024

Thank you for the response, but I already run pnpm run build as you can see in vscode video above.
image

Also, in RubyMine, it points to to dist directory (as video shows above)

@juliusmarminge
Copy link
Member

i see - do you have the workspace typescript version configured? that can sometimes mess with stuff
CleanShot 2024-07-24 at 10 14 05
CleanShot 2024-07-24 at 10 14 14

@dominikjasek
Copy link
Author

Yes, I use workspace version 5.5.4. "Live types" work fine even without running the build. I manually edited post.all procedure to return different object and typescript automatically infers that. So that works fine.
image

But Go to definition does not work. Do you have different behaviour please?

@dominikjasek
Copy link
Author

In adition, if I use typescript workspace version in RubyMine, api is typed as any. If I use bundled version 5.2.2, I get the behaviour from the video above

@abhishek-butola
Copy link

abhishek-butola commented Aug 9, 2024

Same issue. It goes to definition only when this is set

"types": "./src/index.ts"

instead of

"types": "./dist/index.d.ts".

with .d.ts it goes here instead of actual definition

export const appRouter = createTRPCRouter({
  test: testRouter
});

@dominikjasek
Copy link
Author

Same issue. It goes to definition only when this is set

"types": "./src/index.ts"

instead of

"types": "./dist/index.d.ts".

with .d.ts it goes here instead of actual definition


export const appRouter = createTRPCRouter({

  test: testRouter

});

Yes, I also edited it exactly as you did and now it works. Not sure if there are any consequences

@abhishek-butola
Copy link

Same issue. It goes to definition only when this is set

"types": "./src/index.ts"

instead of

"types": "./dist/index.d.ts".

with .d.ts it goes here instead of actual definition


export const appRouter = createTRPCRouter({

  test: testRouter

});

Yes, I also edited it exactly as you did and now it works. Not sure if there are any consequences

vscode performance

@KATT
Copy link

KATT commented Aug 30, 2024

Hm. I suspect this is a bug in TypeScript's declarationMap

@juliusmarminge, does t3-turbo's jump to definition work for you? I get this behavior as well:

CleanShot.2024-08-30.at.21.35.00.mp4

Unsure if there's anything we can do here from tRPC's standpoint

@juliusmarminge
Copy link
Member

Hm. I suspect this is a bug in TypeScript's declarationMap

@juliusmarminge, does t3-turbo's jump to definition work for you? I get this behavior as well:

CleanShot.2024-08-30.at.21.35.00.mp4

Unsure if there's anything we can do here from tRPC's standpoint

I'll take a look on Monday but I know at our work repo I have jump to definition working with declaration emission

@juliusmarminge
Copy link
Member

This will be fixed by microsoft/TypeScript#60005

@juliusmarminge juliusmarminge added blocked upstream problem is on an upstream package bug Something isn't working labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked bug Something isn't working upstream problem is on an upstream package
Projects
None yet
Development

No branches or pull requests

4 participants