'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:
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 ?
Solution 1:[1]
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
Solution 2:[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
Solution 3:[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.
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
Solution 4:[4]
Clear Intellisense temp data:
- Close VS
- Delete .vs folder
- Restart VS
Solution 5:[5]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dylan |
| Solution 2 | joakimriedel |
| Solution 3 | Josh |
| Solution 4 | Ċ½eljko |
| Solution 5 | EKanadily |

