Visual Studio代码自动导入 [英] Visual Studio Code Automatic Imports

查看:247
本文介绍了Visual Studio代码自动导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Webstorm过渡到Visual Studio Code. Webstorm的性能非常糟糕.

I'm in the process of making the move from Webstorm to Visual Studio Code. The Performance in Webstorm is abysmal.

Visual Studio代码对于查找所需的依赖项并将其导入并不是很有帮助.到目前为止,我一直在手动执行此操作,但是老实说,我宁愿等待15秒钟,以便Webstorm查找并添加必须手动挖掘的导入内容.

Visual studio code isn't being very helpful about finding the dependencies I need and importing them. I've been doing it manually so far, but to be honest I'd rather wait 15 seconds for webstorm to find and add my import that have to dig around manually for it.

我正在使用@ minko-gechev中的angular2种子 https://github.com/mgechev/angular2-seed

I'm using the angular2 seed from @minko-gechev https://github.com/mgechev/angular2-seed

我的baseDir中有一个tsconfig.json,如下所示:

I have a tsconfig.json in my baseDir that looks like this:

    {
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "declaration": false,
    "removeComments": true,
    "noLib": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "pretty": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitUseStrict": false,
    "noFallthroughCasesInSwitch": true
  },
  "exclude": [
    "node_modules",
    "dist",
    "typings/index.d.ts",
    "typings/modules",
    "src"
  ],
  "compileOnSave": false
}

并且我的src/client目录中还有另一个看起来像这样的

and I have another one in my src/client dir that looks like this:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "allowSyntheticDefaultImports": true
  }
}

我不知道为什么有两个. Angualr Seed项目使用Typescript gulp构建任务,因此我猜编译是不同的.

I don't know why there are two. The angualr seed project uses typescript gulp build tasks so I guess the compilation is different.

我该如何使vscode变得更有帮助?

What can I do get vscode to be more helpful??

推荐答案

我通过安装各种插件使此工作正常.这是我的扩展程序列表的屏幕截图.在大多数情况下,只要我键入类名,事情就会自己导入.或者,出现一个灯泡,您可以单击.或者,您可以按F1,然后键入"import ...",那里也有各种选项.我有点用了.同样,用于实现界面的F1工具也很有用,但并不总是有效.

I got this working by installing various plugins. Here's a screenshot of my extensions list. Most of the time things just import by themselves as soon as I type the class name. Alternatively a lightbulb appears that you can click on. Or you can push F1, and type "import..." and there are various options there too. I kinda use all of them. Also F1 Implement for implementing an interface is helpful, but doesn't always work.

这篇关于Visual Studio代码自动导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆