Configure "Go to Definition" to Open TypeScript Source

Configure "Go to Definition" to Open TypeScript Source
Nicolas Charpentier
Nicolas Charpentier
November 19, 2025
2 min read

If you are reading this, it's probably because you ended up working with a TypeScript project, configured as a monorepo with project references (or not), soon to realize that every single time you use Go to Definition in your IDE, it leads you to the generated type declarations rather than the source. It could be useful for third-party packages, but when you are actively developing in your own code base, it can be frustrating as you probably want to edit the source, not read types.

Let's fix this!

Within your tsconfig.json, you probably already have declaration defined:

{
  "compilerOptions": {
    "declaration": true
  }
}

This is the step generating the type declarations files (.d.ts) that your IDE is navigating to when you use Go to Definition.

The missing piece here to fix the connection back to the source, is to configure declarationMap, that will generate a source map for .d.ts files which map back to the original .ts source file. Allowing your IDE to navigate to the source instead of the declaration, like you would expect!

Tip

You may need to apply this to all tsconfig.json files depending on your project structure.

{
  "compilerOptions": {
    "declaration": true,
+   "declarationMap": true
  }
}
Note

An explicit reload/restart of the TypeScript server or VS Code might be required after changing tsconfig.json for the changes to be recognized.

No need to manually navigate to the source from the generated .d.ts files anymore!