40

We are getting the following "Error" message in our MVC web application in Visual studio 2017 Enterprise.

The language service is disabled for project 'C:\Work\Blackhawk Platform\Platform-DEV-Branch\BlackhawkViewer\BlackhawkViewer.csproj' because it included a large number of .js files. Consider excluding files using the 'exclude' section of a 'tsconfig.json' file.

I have tried turning off the Language service in the options but this does not turn the message off:

enter image description here

This is a rather large web application. Is there a way to turn this message off without disabling any files in the tsconfig.json file as it suggests?

TResponse
  • 3,940
  • 7
  • 43
  • 63

9 Answers9

44

To solve this issue do the following:

  • Create file in root directory of your project and call it tsconfig.json
  • Add this:
{
  "compilerOptions": {
    "allowJs": true, 
    "noEmit": true, 
    "module": "system",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  },
  "include": [
    "scripts"
  ],
  "exclude": [

  ],
  "typeAcquisition": {
    "enable": true 
  }
}

Please have a look at the below two links for tsconfig.json explanation, because you may still need to change it according to your setup. This is the only way that worked for me. I hope that will help.
https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
https://developercommunity.visualstudio.com/content/problem/8148/javascript-intellisense-not-working.html

David P
  • 761
  • 8
  • 13
  • 5
    Whilst this code snippet is welcome, and may provide some help, it would be [greatly improved if it included an explanation](//meta.stackexchange.com/q/114762) of *how* it addresses the question. Without that, your answer has much less educational value - remember that you are answering the question for readers in the future, not just the person asking now! Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. – Toby Speight Apr 26 '17 at 08:09
  • 1
    this solution didn't work for me, i have lots of javascript files and even excluding one of the folders with lots of js files did not work for me, using the tsconfig.json – inN0Cent May 09 '17 at 00:59
  • 2
    I also have a lot of javascript files and it worked, try to clean the solution, rebuild and restart visual studio might help. – Moustafa Mansour May 10 '17 at 00:36
  • 1
    This is the right answer, and a solid one. Thanks for providing the links too. – Neo Jun 26 '17 at 13:54
  • 2
    I added the above file and now get the error: The config file 'project/tsconfig.json' found doesn't contain any source files. – Allan Nielsen Oct 20 '17 at 02:58
  • This solution does not work. See prior comment by Allan. – Sean Kendle Apr 13 '18 at 15:02
  • @AllanNielsen it's because you have to list the scripts you want to include, or more simply just do a pattern to capture all the scripts. In my solution, including `wwwroot/**/*.js` captures everything. [See this](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) – Corey P Oct 09 '18 at 14:32
21

This helped me. You can have a try.

 Go to Tools -> Options -> Text Editor -> JavaScript/TypeScript -> Language Service -> General

and uncheck the box: "Enable the new JavaScript language service.

oneNiceFriend
  • 6,691
  • 7
  • 29
  • 39
9

I have found a solution for this problem.

I reset my userData using:

devenv.exe /resetuserdata

Since doing this the JavaScript settings seem to have persisted and I no longer get the language service error above.

TAKE NOTE: This will reset all your user data and customisations.

TResponse
  • 3,940
  • 7
  • 43
  • 63
2

In My case I just disable TypeScript support on Visual Studio:

Tools > Extensions and Updates > TypeScript for Microsoft Visual Studio > Disable

After that, just restart Visual Studio, and you are good to go.

Hope this will help,

Asif Raza
  • 971
  • 6
  • 14
1

I had the same problem after migrating Ionic 1 project from VS2015 to VS2017, first I executed git clean -fxd as sugested above and added this content into tsconfig.json in my ionic project.

{
"compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5"
},
"exclude": [
    "node_modules",
    "www",
    "bower_components"
    ]
}
Fabio Campinho
  • 982
  • 8
  • 13
1

I solved this problem with following solution:

When you have a JavaScript file that is included in the project.csproj file but isn't in the project folder, this error occurred.

For example I have a .csproj file like below:

 <ItemGroup>
     <Content Include="Scripts\Test.js" />
 </ItemGroup>

The Test.js is included in the .csproj file, but it isn't in the Scripts folder:

Delete the <Content Include="Scripts\Test.js" /> line from the .csproj file and rebuild your project

TResponse
  • 3,940
  • 7
  • 43
  • 63
Iman Bahrampour
  • 6,180
  • 2
  • 41
  • 64
1

Solution that worked for me:

  1. Go to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE>.
  2. Open command prompt as admin in current folder
  3. Ran devenv /Setup
  4. Ran devenv /ResetSkipPkgs
Pavlo Neiman
  • 7,438
  • 3
  • 28
  • 28
1

For me is helping the next solution. I've create a tsconfig.json file in root of the my project with "disableSizeLimit": "true" option.

So, my tsconfig.json file is:

{
  "compilerOptions": {
  "disableSizeLimit": "true"
},
"exclude": []
}
Andrey Ravkov
  • 1,268
  • 12
  • 21
0

If none of suggested methods worked, try:

npm install -g typescript@latest

and then

Install the latest version of TypeScript for Visual Studio on Get TypeScript.

Murat Yıldız
  • 11,299
  • 6
  • 63
  • 63