Cross-project Go to Definition

In order for the Go to Definition feature in Visual Studio Code to work across projects, we need to set the declarationMap setting in tsconfig.json.

Let's continue with our multiple project example:

  1. Let's open person.ts in ProjectA, right-click on the randomString reference, and select Go to Definition:

  We are taken to the declaration file rather than the source file:

  1. We can resolve that by setting declarationMap in tsconfig.json in the Shared project:
{
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
...
},
}

If we compile the Shared project and try the Go to Definition feature again, we are taken to the source file, as we would want.

So, by setting declarationMap to true in the dependent project, along with composite and declaration, we get great support for multiple TypeScript projects.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.81.94