If you just installed the jQuery TypeScript definition file then will get the above error when you run your application. Here is the error message in full:
Error: typings/globals/jquery/index.d.ts(3218,13): error TS2403: Subsequent variable declarations must have the same type. Variable '$' must be of type 'cssSelectorHelper', but here has type 'JQueryStatic'.
The reason you’re getting this error is because the $ variable it defined twice in your application. Of course, it’s defined in the jQuery type definition file you just installed, but it’s also defined in the angular-protractor library. You may not know anything about angular-protractor, but it’s installed in the Aurelia framework by default so you can perform end-to-end testing of your app.
This is an interesting error because it is a TypeScript transpiler error only and jQuery still runs fine. Although Protractor declares a $ variable that conflicts with jQuery, you don’t actually load Protractor into memory when running your app. So there is no conflict with jQuery during runtime.
The problem occurs because the Protractor TypeScript definition file is global and is loaded by the transpiler even if the actual .js library itself isn’t being loaded. There’s no harm, it’s just a hassle b/c your jQuery methods aren’t going to be found by your TypeScript editor since the $ variable was defined first in Protractor. And having a lot of red squiggly lines in your editor doesn’t exactly give you a warm fuzzy feeling either.
To fix this error just delete the Protractor definition files from your application. You’ll still be able to run Protractor if you wish to do end-to-end testing, but you just won’t have the .d.ts files in your app. To delete Protractor first remove it with the typings command:
typings uninstall angular-protractor --global typings uninstall aurelia-protractor --global
Once you’ve done that, all traces of the Protractor TypeScript library will be gone and you’ll be able to call jQuery methods with no errors!