类型“jQueryStatic <telement extends =”“node =”“>”的值不可调用

时间:2017-09-13 23:51:30

标签: jquery typescript visual-studio-2017 resharper definitelytyped

问题: Visual Studio IntelliSense在$Value of type “jQueryStatic<TElement extends Node>” is not callable

时大叫

示例代码$的所有实例,真的):

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

设定:

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>

一切都建立并且运行良好。任何人都有任何线索?

2 个答案:

答案 0 :(得分:2)

事实证明问题在于Resharper(Value of type "JqueryStatic" is not callable)。这是我所做的一切清单:

答案 1 :(得分:1)

  

“jQueryStatic”类型的值不可调用

类型definiton和typescript编译器版本之间的兼容性问题引起的。

修复

升级到最新的打字稿(2.5.2)并确保jquery.d.ts(或@types/jquery)是最新的。