microsoft / microsoft/TypeScript

VSCode not respecting declaration map without absolute sourceRoot

Open
#62,009 3 comments 0 reactions 0 assignees View on GitHub
7.0 LS Migration
Dominant language
Go
Stars
111k
Forks
14.3k
PR merge metrics
PR metrics pending

Description

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:

1. Clone https://github.com/ishchhabra/pnpm-workspace-example
2. Open `apps/web/src/app/page.tsx` and CMD+Click on `Link`. It'll open the `Link.d.ts` file (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.

Contributor guide

Open the contributing guide

Research direction

Reproduce the navigation from apps/web/src/app/page.tsx to Link.d.ts using the pnpm-workspace-example, then compare packages/ui/tsconfig.json with absolute and relative sourceRoot values. Inspect how the declaration map is resolved and verify that the relative setting navigates to packages/ui/src/components/Link.tsx without per-app paths overrides.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.