Jquery with Typescript : Property 'css' does not exist on type 'ElementFinder'

廉价感情. 提交于 2019-12-04 20:03:11

You'll need to define jQuery typings, I'm using :

https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/jquery/jquery.d.ts

And it's working fine for me .

I had the same issue and I had to download this typings myself and put it in my folders somewhere .

Then in your tsconfig.js

  "files": [
    "./src/app/**/*.ts",
    "./src/platform/**/*.ts",
    "!./node_modules/**",
    "./src/custom-typings.d.ts",
    "./src/jquery-typings-custom/index.d.ts",  !!!!!!! This is the folder where I put those typings downloaded from the url
    "./src/vendor/slick/slick-typings.d.ts",
    "./typings/index.d.ts"
  ],

And then , in one of your components ( probably the root one , which is normally app.ts ) you should do :

       declare var jQuery : JQueryStatic;

And then instead of using $ , you should start using jQuery(There is a workaround for this issue as well , but I didn't care ) .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!