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

相關問題