简体   繁体   English

VSCode - Lerna - 打字稿 - Monorepo代码导航

[英]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.

相关问题 TypeScript Lerna/MonoRepo Webpack 开发速度/优化 - TypeScript Lerna/MonoRepo Webpack development speed/optimization 如何使用打字稿解决lerna monorepo中sequelize和angular之间的冲突? - How to solve conflict between sequelize and angular in lerna monorepo with typescript? 带有 Lerna 和 TypeScript 的 Monorepo 无法按路径别名导入包 - Monorepo with Lerna and TypeScript fails to import package by path alias Typescript 编译器在 Lerna monorepo 的 s 包中发出单个声明文件 - Typescript Compiler emit a single declaration file in s package of a Lerna monorepo 在 VSCode 中调试 lerna-typescript 项目 - Debugging a lerna-typescript project in VSCode VSCode / w。 更漂亮的TypeScript Monorepo - VSCode /w. Prettier in TypeScript Monorepo Typescript 别名不适用于 monorepo 中的 VSCode Eslint - Typescript aliases not working with VSCode Eslint in monorepo 具有共享 typescript 代码的 SPFx monorepo - SPFx monorepo with shared typescript code "如何汇总以在其转译(TypeScript)中包含来自另一个包的依赖项?" - How to get rollup to include a dependency from another package in a lerna monorepo in its transpilation (TypeScript)? 如何在带有 Lerna 和 Yarn 工作区的 Typescript monorepo 中启用热重载? - How do you enable hot reloading in a Typescript monorepo with Lerna and Yarn Workspaces?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM