t3-oss / create-t3-turbo

Clean and simple starter repo using the T3 Stack along with Expo React Native
https://turbo.t3.gg
MIT License
4.51k stars 375 forks source link

bug: go to definition is not working #1124

Open dominikjasek opened 1 month ago

dominikjasek commented 1 month ago

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?

https://github.com/user-attachments/assets/352ce458-9dca-418c-b134-107d48a1f81e

https://github.com/user-attachments/assets/73f75a82-4a1a-4bf4-92cd-5af17df6c3ea

Link to reproduction

none, just clone template repo

To reproduce

Clone repo, try to navigate to definition

juliusmarminge commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 week ago

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:

https://github.com/user-attachments/assets/6b1716af-b475-4526-9db9-5534d6f04b70

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

juliusmarminge commented 1 week ago

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:

https://github.com/user-attachments/assets/6b1716af-b475-4526-9db9-5534d6f04b70

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