[英]typescript paths with vscode resolve wrong on ctrl click
I have a library whose source code I am modifying, I downloaded the source code for it and wanted to point vscode, typescript & webpack towards that file.我有一个正在修改其源代码的库,我下载了它的源代码并想将 vscode、typescript 和 webpack 指向该文件。
In webpack I aliased the library successfully, but vsc doesn't seem to want to use the files
property of tsconfig.json
over the node_modules
.在 webpack 中,我成功地为库添加了别名,但 vsc 似乎不想在tsconfig.json
上使用node_modules
的files
属性。
When ctrl clicking an import like当 ctrl 单击导入时
import {myModule} from "myModule/breh"
with a tsconfig
like this使用这样的tsconfig
"baseUrl": "src",
"paths": {
"myModule/*": ["myModule/src/*"]
}
it doesn't go to the correct path, it always goes to node_modules
.它没有 go 到正确的路径,它总是去node_modules
。
The location of the library is under src/myModule/src
.库的位置在src/myModule/src
下。
of course.当然。 The recommended baseUrl is node_modules.推荐的 baseUrl 是 node_modules。 So errthing should le relative to it which means the correct path you need to add in paths is所以错误应该相对于它,这意味着您需要在路径中添加的正确路径是
"baseUrl":"./node_modules",
"paths": {
"exact name as in the import": ["../dir/file.d.ts"]
}
As the base is node modules you need to tell it to out at its father dir由于基础是节点模块,因此您需要在其父目录中告诉它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.