How to disable automatic import statements in VsCode October 2017

The latest version of VS Code, installed a few days ago (October 2017 update), adds all kinds of weird import statements to the top of the .ts code file.

For example, when I edited a file, VsCode unexpectedly added a line to the top of the file:

import { Stack } from "../../../../../../../../../Repos/Web/node_modules/@types/d3"; 

How to disable this behavior?

+28
source share
5 answers
 "typescript.suggest.autoImports": false "javascript.suggest.autoImports": false 

The latest version of VS Code. February 2019

+25
source

You can disable it by adding this line to your user or workspace settings ( File>Preferences>Settings or Code>Preferences>Settings ).

 "typescript.autoImportSuggestions.enabled": false 

Ref .: https://github.com/Microsoft/vscode/issues/38551

+28
source

As of August 2018 (1.25), the accepted answer does not always work.

Instead, add this line to your folder setting.

 { "typescript.preferences.importModuleSpecifier": "relative" } 

Do not think what is happening here, but these automatic path changes never happen in my environment.

0
source

For those using React / JavaScript, you should edit this option under File> Preferences> Preferences:

 "javascript.updateImportsOnFileMove.enabled": "never", 
0
source

Updated for the new version of VSCode 2019 to use the user interface to change settings. Therefore, select File> Preferences> Settings , and then search for auto in the Workspace section. Find Javascrtip or Typescript with the word auto import highlighted, then check or uncheck the box to enable / disable this function.

Here is a picture for reference.

enter image description here

0
source

Source: https://habr.com/ru/post/1273469/


All Articles