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

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.

主站蜘蛛池模板: 黄山市| 宜黄县| 安仁县| 汾西县| 乳山市| 大竹县| 浪卡子县| 顺义区| 永吉县| 上虞市| 穆棱市| 涞源县| 霍城县| 凤翔县| 南漳县| 东海县| 喀什市| 潮安县| 云和县| 盈江县| 遂川县| 金沙县| 浦江县| 白水县| 宁都县| 枝江市| 阿克苏市| 拉孜县| 广昌县| 江北区| 普格县| 阳曲县| 包头市| 太康县| 周至县| 杂多县| 莱西市| 重庆市| 景泰县| 绍兴县| 江阴市|