[英]How to properly set up Ember auto-imports using VSCode and the Javascript Language Service?
I'm trying to set up auto-imports in VSCode for my Ember project and I'm encountering issues with imports from the Ember library. 我正在尝试为我的Ember项目在VSCode中设置自动导入,并且遇到从Ember库导入的问题。
I have properly set up imports from within my application, those work just fine, but when trying to import from @ember
, it either doesn't find the import at all, or it's imported from a ridiculous relative path, or it's imported just fine, in some cases. 我已经从我的应用程序中正确设置了导入,这些工作正常,但是当尝试从@ember
导入时,它根本找不到导入,或者是从一个荒谬的相对路径中导入的,或者只是导入而已,在某些情况下。
My jsconfig.json
looks like this: 我的jsconfig.json
看起来像这样:
{
"compilerOptions": {
"target": "es2018",
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"sbct-web/tests/*": ["./tests/*"],
"sbct-web/config/*": ["./config/*"],
"sbct-web/*": ["./app/*"]
}
},
"exclude": [
"node_modules",
"bower_components",
"tmp",
"vendor",
".git",
"dist",
"temp",
"public",
]
}
I also tried with a dumbed down version that only had the exclude
field, but the results were the same. 我还尝试了一个仅具有exclude
字段的精简版本,但结果是相同的。 I also tried to force typeAcquisitions
, same results (I suspect the types are fetched just fine, because I can peek definitions of @ember modules). 我还尝试强制typeAcquisitions
,得到相同的结果(我怀疑类型可以很好地获取,因为我可以窥视@ember模块的定义)。
In order to better understand the issue, here's a short recording of what I'm encountering: 为了更好地理解问题,以下是我遇到的简短记录:
The VSCode IntelliSense for javascript works from the type definitions in your package.json javascript的VSCode IntelliSense可从package.json中的类型定义进行工作
I've found that be specifically adding the @types/ember package. 我发现这是专门添加@ types / ember包。 VSCode is able to properly auto-import. VSCode能够正确自动导入。
npm install --save-dev @types/ember
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.