VSCode not respecting declaration map without absolute sourceRoot
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.101.2
- OS Version: MacOS 15.1.1
Steps to Reproduce:
- Clone https://github.com/ishchhabra/pnpm-workspace-example
- Open
apps/web/src/app/page.tsxand CMD+Click onLink. It'll open theLink.d.tsfile (from dist).
If I add
"sourceRoot": "/Volumes/Development/pnpm-workspace-example/packages/ui/src" to packages/ui/tsconfig.json, it takes me to the Link.tsx file in packages/ui/src/components, however, using "sourceRoot": "./src" takes user to the declaration file in dist/.
I am able to workaround by adding "@packages/ui": ["../../packages/ui/src"] in paths in the tsconfig for apps/web, however that is not ideal since that requires defining paths in every app that uses the package.
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.101.2. Please try upgrading to the latest version and checking whether this issue remains.
Happy Coding!
Just tried with latest version of VSCode as well. Same behavior.
🤖 Thank you for your issue! I've done some analysis to help get you started. This response is automatically generated; feel free to 👍 or 👎 this comment according to its usefulness.
Similar Issues
Here are the most similar issues I found:
- (77%) microsoft/typescript#49934: The "declarationMap" compiler flag does not work in conjunction with the "sourceMapRoot" compiler flag + relative paths
- (73%) microsoft/typescript#25322: VSCode doesn't respect sourceRoot in declarationMaps
- (70%) microsoft/typescript#23180: Generating source maps with relative path in sourceRoot option produces maps with abosolute file paths
- (68%) microsoft/typescript#5180: sourceRoot should support relative paths and respect folder hirearchy
- (68%) microsoft/typescript#25662: "Go to definition" not working with `declarationMap` and projects references
- (68%) microsoft/typescript#25508: Navigating to a Module that is represented by d.ts file (with provided declaration map) works incorrectly on Windows
- (67%) microsoft/typescript#25792: VS 201x and VS Code are not able to find real source with declarationMaps
- (67%) microsoft/typescript#1513: Calculation of paths in the “sources” field of source-maps generated by tsc
- (67%) microsoft/typescript#61001: Go to definition through sub-packages
- (66%) microsoft/typescript#60004: Source mappings are missing for serialized properties
- (66%) microsoft/typescript#12246: Source maps are not relative to rootDirs
- (66%) microsoft/typescript#35670: Is possible to use sourceRoot to point a folder inside outDir and generate the paths relatively to that folder
- (66%) microsoft/typescript#11678: reference path apparently ignores rootDir(s)
- (66%) microsoft/typescript#10612: Not producing relative sourceMappingUrl's with mapRoot
- (66%) microsoft/typescript#52082: VSCode "go to definition" in TypeScript goes to node_modules instead of resolving symlink
If your issue is a duplicate of one of these, feel free to close this issue. Otherwise, no action is needed. Thanks!