admin管理员组文章数量:1356236
I have an error in the declaration file of angular:
TS2304: Cannot find name 'JQueryStatic'.
I do have the typings of jquery installed. There, JQueryStatic is declared as an interface.
How can I solve it?
I have an error in the declaration file of angular:
TS2304: Cannot find name 'JQueryStatic'.
I do have the typings of jquery installed. There, JQueryStatic is declared as an interface.
How can I solve it?
Share Improve this question asked May 11, 2017 at 16:47 AlonAlon 12k28 gold badges103 silver badges172 bronze badges 4- Please show us your code – Alon Eitan Commented May 11, 2017 at 16:48
- 1 are you using SignalR by any chance? – Kumar Nitesh Commented May 11, 2017 at 16:51
- @Knitesh no, I'm not. – Alon Commented May 11, 2017 at 16:55
- Really need some code and context here. "When" do you get this error? In your IDE? When you run the code? Where did you install the typings? In node_modules/@types ? Because then you also need to add it in your tsconfig.: "typeRoots": ["node_modules/@types/"] – therebelcoder Commented May 11, 2017 at 16:58
2 Answers
Reset to default 8Same problem with me. (Angular 6)
Here's how I resolved it:
Step 1: npm install jquery
Step 2: npm install --save-dev @types/jquery
Step 3: Go to file angular.json
Add code below in scripts: [...]
"node_modules/jquery/dist/jquery.min.js"
Step 4: Go to file src/typings.d.ts
Add code below
import "jquery";
declare var $: JQueryStatic;
declare var jQuery: JQueryStatic;
Now you can use $
or jQuery
inside the typescript ponent.
I fixed it by adding a reference to jquery:
///<reference path="../jquery/index" />
本文标签: javascriptangular39s definelytyped doesn39t recognize JQueryStaticStack Overflow
版权声明:本文标题:javascript - angular's definelytyped doesn't recognize JQueryStatic - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744054008a2582940.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论