[英]VSCode - Lerna - Typescript - Monorepo Code Navigation
We have a monorepo for all our Javascript related SDKs here at Sentry. 我们在Sentry的所有与Javascript相关的SDK都有一个monorepo。 https://github.com/getsentry/sentry-javascript
https://github.com/getsentry/sentry-javascript
If you clone this repo, set it up properly with yarn install
and then open any file like packages/node/src/backend.ts
and try to jump to the implementation of another package like the function limitObjectDepthToSize
that lives in the utils
package. 如果您克隆此repo,使用
yarn install
正确设置它,然后打开任何文件,如packages/node/src/backend.ts
并尝试跳转到另一个包的实现,如utils
包中的函数limitObjectDepthToSize
。
First of all, if you did not build the project before (have all type definitions in place) this error pops up: 首先,如果您之前没有构建项目(具有所有类型定义),则会弹出以下错误:
But even if you built everything before, CMD+Click
on the function now always jumps to the built object.d.ts
instead of what I really want is that it jumps to the implementation source file which can be found in packages/utils/src/object.ts
instead of /packages/utils/object.d.ts
. 但即使您之前构建了所有内容,
CMD+Click
现在CMD+Click
该函数总是跳转到构建的object.d.ts
而不是我真正想要的是它跳转到可以在packages/utils/src/object.ts
找到的实现源文件packages/utils/src/object.ts
而不是/packages/utils/object.d.ts
。
My question now is, is our setup wrong, is there any option in VSCode or maybe tsconfig.json
that fixes this code navigation? 我现在的问题是,我们的设置是错误的,VSCode中是否有任何选项或修复此代码导航的
tsconfig.json
?
Or is this a currently known limitation of VSCode in monorepo environments? 或者这是单核环境中VSCode的当前已知限制?
Any help is appreciated and I hope it's nothing really obvious I just missed, thanks! 任何帮助都表示赞赏,我希望我错过的并不是很明显,谢谢!
Set declarationMap
to true
to generates a sourcemap for each corresponding '.d.ts' file. 将
declarationMap
设置为true
可为每个对应的“.d.ts”文件生成源图。 It will allow IDE to jump to correct line at implementation file. 它将允许IDE跳转到实现文件中的正确行。
TS Documentation :
TS文档 :
We've also added support for declaration source maps.
我们还增加了对声明源地图的支持。 If you enable --declarationMap, you'll be able to use editor features like “Go to Definition” and Rename to transparently navigate and edit code across project boundaries in supported editors.
如果启用--declarationMap,您将能够使用编辑器功能,如“转到定义”和重命名,以在支持的编辑器中跨项目边界透明地导航和编辑代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.