Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable intellisense for default typescript libraries in VSCODE

In visual studio code, using typescript, I get unwanted suggestions when using the intellisense/autocomplete feature.

Examples:

HTMLAllCollection
DOMError

etc...

The reason seems to be that intellisense automatically includes all files in

{vscode dir}/resources/app/extensions/node_modules/typescript/lib

Is there any way to disable intellisense for these?

In the end I want intellisense to only include things that are explicitly related to my project.

like image 760
Gerrit Begher Avatar asked Aug 03 '19 09:08

Gerrit Begher


2 Answers

In order to control which libraries are loaded in your project and are providing intellisense/autocomplete you need to configure lib property [array type] of compilerOptions in your tsconfig.json file.

If lib property is not configured, TypeScript will automatically load following libraries:

  • For target ES5: DOM, ES5, ScriptHost.
  • For target ES6: DOM, ES6, DOM.Iterable, ScriptHost.

Example configuration in tsconfig.json file could look like this:

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "es2017"
    ]
  }
}

This would load only libraries for ECMAScript 2017 intellisense.

You can read more about compiler options, including lib here: https://www.typescriptlang.org/docs/handbook/compiler-options.html

like image 123
Nenad Avatar answered Sep 20 '22 11:09

Nenad


Open the Settings editor File > Preferences > Settings (Code > Preferences > Settings on macOS

snippets : To disable basic TypeScript snippets you can set editor.snippetSuggestions to "none" in your settings file. If you'd like to see snippets, you can specify the order relative to suggestions; at the top ("top"), at the bottom ("bottom"), or inlined ordered alphabetically ("inline"). The default is "inline" enter image description here

JSDoc support: To disable JSDoc comment suggestions in TypeScript, set "typescript.suggest.completeJSDocs": false enter image description here

Auto imports: You can disable auto imports by setting "typescript.autoImportSuggestions.enabled": false enter image description here

Formatting: set "typescript.format.enable" to false to disable it.

JSX and auto-closing tags: Set "typescript.autoClosingTags" to false to disable JSX tag closing. enter image description here

Unused variables and unreachable code: To disable fading out of unused code, set "editor.showUnused" to false. You can also disable fading of unused code only in TypeScriptScript by setting,

"[typescript]": {
    "editor.showUnused":  false
},
"[typescriptreact]": {
    "editor.showUnused":  false
},

enter image description here

Code suggestions: Set "typescript.suggestionActions.enabled" to false to disable suggestions. enter image description here

You can read more on https://code.visualstudio.com/docs/languages/typescript

like image 20
INDRAJITH Avatar answered Sep 21 '22 11:09

INDRAJITH