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

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.

主站蜘蛛池模板: 九寨沟县| 肇东市| 余庆县| 长寿区| 烟台市| 天峻县| 邵阳市| 宜君县| 黄大仙区| 石嘴山市| 深泽县| 昌平区| 宣城市| 靖江市| 淅川县| 新余市| 确山县| 高青县| 渑池县| 法库县| 英超| 油尖旺区| 安多县| 龙泉市| 辽源市| 右玉县| 望都县| 射阳县| 通渭县| 黎川县| 赤峰市| 茂名市| 淮南市| 五指山市| 额尔古纳市| 屯门区| 霍邱县| 阳西县| 元朗区| 顺平县| 牙克石市|