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

Go to definition through sub-packages #61001

Open
KATT opened this issue Jan 20, 2025 · 0 comments
Open

Go to definition through sub-packages #61001

KATT opened this issue Jan 20, 2025 · 0 comments

Comments

@KATT
Copy link

KATT commented Jan 20, 2025

🔎 Search Terms

go to to definition, sub-packages, nested packages, declaration maps, sourcemap, monorepo

🕗 Version & Regression Information

⏯ Playground Link

https://github.com/KATT/typescript-go-to-definition-through-sub-packages

💻 Code

TypeScript's "Go to Definition" does not work through multiple levels of package imports. Here's the setup:

  1. Package @org/a defines a base object:

    export const a = {
    	foo: 'foo',
    	bar: 'bar',
    	baz: 'baz',
    	qux: 'qux',
    } as const;
  2. Package @org/b imports and re-exports package @org/a's object:

    import { a } from '@org/a';
    
    a; // ✅ Go to definition works here with ^5.7.3
    a.foo; // 🚧 Go to definition does not work here, but seemingly fixed by https://github.com/microsoft/TypeScript/pull/60005
    
    export const b = {
    	a,
    } as const;
  3. Package @org/c imports from package @org/b and tries to access the nested property:

    import { b } from '@org/b';
    
    b; // 🚧 Go to definition does not work here, but seemingly fixed by https://github.com/microsoft/TypeScript/pull/60005
    b.a; // <--- 🚧 Go to definition does not work here, but seemingly fixed by https://github.com/microsoft/TypeScript/pull/60005
    b.a.foo; // <--- ❌ Go to definition does not work here

🙁 Actual behavior

🙂 Expected behavior

Go to definition should work through multiple levels of package imports as if the code was written in a single file.

Additional information about the issue

Partially addressed by #60005, I'm using npm:@kitchensink/typescript-pr60005@latest in the repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant