Value of type “jQueryStatic<TElement extends Node>” is not callable

802 Views Asked by At

Issue: Visual Studio IntelliSense yells at $: Value of type “jQueryStatic<TElement extends Node>” is not callable

Example code (All instances of $, really):

const emaildiv = $("<div>", { "class": "email-item" });
$(containerid).append(emaildiv);

Setup:

tsconfig.ts:

 {
   "compilerOptions": {
     "lib": [ "es2015", "es2015.iterable", "dom" ],
     "noImplicitAny": true,
     "noEmitOnError": true,
     "removeComments": false,
     "sourceMap": true,
     "target": "es5"
   },
   "files": [
     // a bunch of local files...
   ],
   "compileOnSave": true
 }

.csproj:

   <PropertyGroup>
     <TargetFramework>netcoreapp2.0</TargetFramework>
     <TypeScriptToolsVersion>2.3</TypeScriptToolsVersion>
   </PropertyGroup>

   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />
   </ItemGroup>

   <ItemGroup>
     <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
   </ItemGroup>

   <ItemGroup>
     <!-- other .ts files -->
     <TypeScriptCompile Include="Scripts\Scripts.ts" />
   </ItemGroup>

   <ItemGroup>
     <Folder Include="wwwroot\scripts\" />
   </ItemGroup>

 </Project>

Everything builds and works fine. Anyone has any clue?

2

There are 2 best solutions below

0
Cescante On BEST ANSWER

As it turns out the issue is with Resharper again (Value of type "JqueryStatic" is not callable). Here's a list of everything I did:

1
basarat On

Value of type “jQueryStatic” is not callable

Caused by compatability issues between the type definiton and typescript compiler version.

Fix

Upgrade to typescript latest (2.5.2) and make sure jquery.d.ts (or @types/jquery) are up to date.