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

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.

主站蜘蛛池模板: 开阳县| 镇原县| 洛浦县| 武夷山市| 绥宁县| 云浮市| 项城市| 蒙阴县| 垫江县| 南雄市| 金山区| 汉源县| 陆丰市| 乳源| 昂仁县| 永康市| 加查县| 鄂州市| 油尖旺区| 临澧县| 宁波市| 河曲县| 军事| 固始县| 河间市| 安图县| 连江县| 黄冈市| 望都县| 徐汇区| 泰兴市| 黄浦区| 桦甸市| 文化| 芷江| 汪清县| 卢龙县| 怀来县| 吉木乃县| 木里| 景泰县|