How to disable automatic import statements in VsCode October 2017

TypescriptVisual Studio-Code

Typescript Problem Overview


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

For example, as I was editing a file, VsCode suddenly added a line like this to the top of the file:

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

How do I disable this behavior?

Typescript Solutions


Solution 1 - Typescript

"typescript.suggest.autoImports": false 
"javascript.suggest.autoImports": false

Fresh VS Code version. February 2019

Solution 2 - Typescript

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

Solution 3 - Typescript

Updated for new version of VSCode 2019 for using the UI to modify the setting. So choose the File > Preference > Setting then search auto in the Workspace secton. Find the Javascrtip or Typescript with highlight word auto import then check or uncheck for enable / disalbe this function.

Here is the picture for reference.

enter image description here

Solution 4 - Typescript

As of August 2018 (1.25), the accepted answer doesn't always work.

Instead, add this line to your folder-specific setting.

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

Don't figure what's going on here, but those automatic path changes never happen in my environment.

Solution 5 - Typescript

For those using React/JavaScript you have to edit this setting in File > Preferences > Settings:

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionprmphView Question on Stackoverflow
Solution 1 - TypescriptEvgeniy ZaykovView Answer on Stackoverflow
Solution 2 - TypescriptAntoine Boisier-MichaudView Answer on Stackoverflow
Solution 3 - TypescriptnahoangView Answer on Stackoverflow
Solution 4 - TypescriptQuvView Answer on Stackoverflow
Solution 5 - TypescriptKurt WilliamView Answer on Stackoverflow