Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable typescript INTELLISENSE errors in VS 2019?

I'm using the typescript but I use it through webpack and babel, so in my ts code imports should be commented out:

// import * as $ from 'jquery';

Otherwise I get errors on babel side. I can't find better way. This works.

But then VS 2019 INTELLISENSE start reporting me many errors:

enter image description here

And I can't do anything with this. Doesn't work

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> 

Possibly because of they are not MSBuild error, but Interllisense.

I have removed the

<TypeScriptToolsVersion>4.1</TypeScriptToolsVersion>

Then VS shows me the warning "please install typescript" and... the same errors list. Possibly because VS ignores it if obtain the tsconfig.json (which I steel need, babel uses it).

Unload/Reload project doesn't help.

How to instruct intellisense do not show me TS2581 and TS2503 at least as errors ?

like image 407
Roman Pokrovskij Avatar asked Nov 14 '22 21:11

Roman Pokrovskij


1 Answers

This does not answer your question directly but could be helpful.

If your like me and have node_modules some of them have tsconfig.json files which visual studio will pick up automatically. it appears to be a solution wide search. Visual studio will then try to run the TSC automatically on it which will throw errors depending on the module. I think it's mostly related to the dev dependencies not being installed.

vs-tsconfig-fix.js

I added a post build step to my package.json that will just go around and delete the tsconfig.json file from any node_modules.

I think it should be find for most modules to delete this because most of them are already transpiled for you

in your tsconfig.json file ensure you have the exclude node_modules and you should not get any intelisense errors.

You might still get the errors if you open the files from node_modules but from my testing if you close it the errors will disappear.

TL;DR running this script will delete all tsconfig.json from node_modules which visual studio is picking up

like image 136
Josh Avatar answered Dec 19 '22 04:12

Josh