官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 汝州市| 城步| 沈阳市| 中江县| 余姚市| 柳江县| 邢台市| 长乐市| 丹巴县| 扬州市| 九龙县| 巍山| 宁津县| 白水县| 罗甸县| 宝鸡市| 桃源县| 铜鼓县| 罗定市| 福海县| 德化县| 株洲市| 象州县| 景谷| 娱乐| 邢台市| 太仆寺旗| 砚山县| 白玉县| 英德市| 阆中市| 鲁甸县| 通河县| 平泉县| 霍城县| 呼图壁县| 天等县| 鸡西市| 庆阳市| 遵化市| 全州县|