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

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.

主站蜘蛛池模板: 武平县| 会同县| 榆社县| 乌兰浩特市| 梧州市| 朝阳市| 海宁市| 荣昌县| 曲水县| 芮城县| 淮北市| 汝南县| 广水市| 禹城市| 哈尔滨市| 道真| 依安县| 广饶县| 当雄县| 裕民县| 高清| 攀枝花市| 金寨县| 将乐县| 日土县| 辉南县| 札达县| 镇沅| 枣庄市| 金沙县| 屏东县| 宁夏| 兰州市| 吉隆县| 包头市| 南汇区| 井冈山市| 且末县| 喀喇| 张北县| 娄烦县|