3

问题: 的Visual Studio智能感知骂$Value of type “jQueryStatic<TElement extends Node>” is not callable值类型的“jQueryStatic <TElement延伸节点>”不是可调用

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

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> 

一切都建立并正常工作。任何人有任何线索?

+1

您的'$'示例代码中没有调用。至少有一些括号或某处。请提供更多背景。 – recursive

+0

@recursive添加示例代码。 '$'的所有实例。 – Cescante

回答

2

事实证明,问题是再次与Resharper(Value of type "JqueryStatic" is not callable)。这里的一切,我做了一个清单:

+0

答案有用和适当,它为我工作 – alhpe

1

型“jQueryStatic”的价值是不可呼叫

由类型definiton和打字稿编译器版本之间的兼容性问题导致的。

修复

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

+0

感谢您的回复。将csproj移到2.5.2并重新定义了类型定义。仍然是同样的问题。 – Cescante

相关问题