How to disable typescript INTELLISENSE errors in VS 2019?
Asked Answered
E

5

14

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 ?

Epigraphic answered 10/5, 2021 at 23:41 Comment(0)
S
3

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

Southwards answered 6/4, 2022 at 22:42 Comment(0)
A
2

As far as I know, visual studio cannot suppress specified errors for typescript file in visual studio editor. You can create a suggestion here: https://developercommunity.visualstudio.com/report?space=8&entry=suggestion

Ancohuma answered 11/5, 2021 at 5:47 Comment(0)
A
2

Like you, I've tried so many ways to get rid of these errors, but to no avail. This is obviously a feature, and not a bug, of Visual Studio.

See the following old issue reported here:

https://developercommunity2.visualstudio.com/t/TypeScriptCompileBlocked-but-IntelliSens/26054

I've added the following suggestion for the VS team. Fingers crossed that they will do something about this!

https://developercommunity.visualstudio.com/t/Make-IntelliSense-respect-TypescriptComp/1580469

Argumentation answered 11/11, 2021 at 12:52 Comment(0)
U
1

Clear Intellisense temp data:

  1. Close VS
  2. Delete .vs folder
  3. Restart VS
Union answered 7/1, 2022 at 15:29 Comment(1)
How to clear intellisense temp data?Gynecoid
B
1

as a work around i put all my frontend files ( source directory , webpack config files , npm config files , node_modules dir ) in the parent directory of the visual studio project directory. this way when you open the project in visual studio : visual studio is completely unaware that there is a webpack project in it's parent directory and it will not complain about typescript.

i open the parent directory in another editor like vs code and configure webpack to output its files in /myProject/wwwroot directory.

this way you will bypass visual studio "supervision" and offload that to vs code. it is a hack but it works if your computer have the horsepower for it.

Bronchus answered 5/2, 2022 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.