Skip to content

Conversation

rgoomar
Copy link

@rgoomar rgoomar commented Aug 22, 2025

These changes made it so I could go to a proper definition. This approach aligns with the way the TypeScript version of the compiler does it using VFS only and VLQ decoding.

Basically we have a situation where we have an import in a .ts file like

import { getLogger } from '@latticehr/o11y';

in a directory like apps/app-one in an index.ts file and the @latticehr is an alias that should reference packages/o11y and it does go to the packages/o11y/dist/*.d.ts file although not the source file implementation

This gets to the correct file and line position using VLQ decoding like the TS version does. This also enables the differentiation between "Go to Definition" and "Go to Type Definition". They both work now.

I'd love to get some feedback and modify this to fit standards that you all have.

@rgoomar
Copy link
Author

rgoomar commented Aug 23, 2025

@microsoft-github-policy-service agree

@rgoomar rgoomar changed the title [WIP] fix go to definition fix go to definition Aug 23, 2025
@rgoomar rgoomar changed the title fix go to definition [LSP] fix go to definition Aug 23, 2025
@alexwork1611
Copy link

Keeping an eye on this...

Comment on lines 147 to 148
// Fallback to underlying FS for files not tracked by the program (like .d.ts.map)
return fs.source.FS().ReadFile(path)
Copy link
Member

@iisaduan iisaduan Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be added onto the compilerhost since d.ts.map is only used by ls features. Can you refactor so only the calls to readFile in definitionSourceMap has this fallback for d.ts.map files? It should probably also read into the snapshot's fs, instead of the underlying file system

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll adjust that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iisaduan I made the change with an alternative method here. Turns out that fs.source.FS() is the snapshot FS

@rgoomar rgoomar requested a review from iisaduan August 25, 2025 22:35
@rgoomar
Copy link
Author

rgoomar commented Aug 27, 2025

This is working for multiple engineers internally for us 😄

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

Successfully merging this pull request may close these issues.

3 participants