Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jquery error #435

Closed
liu-kanghui opened this issue Mar 18, 2016 · 6 comments
Closed

Jquery error #435

liu-kanghui opened this issue Mar 18, 2016 · 6 comments

Comments

@liu-kanghui
Copy link

I followed the instruction over wiki on how to install jquery.

I got the following error :
Subsequent variable declarations must have the same type. Variable '$' must be of type 'cssSelectorHelper', but here has type 'JQueryStatic'.

and when i do
import $ from "jquery" it shows jquery module doesn't exist??

Thanks for help any!!!!

@kschio
Copy link

kschio commented Mar 19, 2016

Probably caused by the type definition.

Replace the following lines at the bottom of the files ../typings/browser/ambient/jquery/index.d.ts and ../typings/main/ambient/jquery/index.d.ts

declare module "jquery" {
    export = $;
}
declare var jQuery: JQueryStatic;
declare var $: JQueryStatic;

with:

declare module "jquery" {
    export = jQuery;
}
declare var jQuery: JQueryStatic;

After that you should be able to import jQuery as import 'jquery';. I briefly checked it so most likely not the cleanest solution. Hope it helps though.

Notice
You need to use jQuery instead of $ if you followed the changes above.

@sergiomedinavalentin
Copy link

@kschio the files ../typings/browser/ambient/jquery/index.d.ts and ../typings/main/ambient/jquery/index.d.ts don't exists. In the file ../typings/jquery/jquery.d.ts , replace

declare module "jquery" {
    export = $;
}
declare var jQuery: JQueryStatic;
declare var $: JQueryStatic;

with:

declare module "jquery" {
    export = jQuery;
}
declare var jQuery: JQueryStatic;

but not working if you import jquery in the files that you need and use jQuery instead of $...

Installation I've followed has been: https://codedump.io/share/kQF7Ts1Iu5d/1/how-to-use-jquery-with-angular2

Thanks for help

@samvloeberghs
Copy link
Contributor

this is not a good approach, as anyone(including you) who will get the code and install it on some other workstation will not have this change. It's something you need to remember or put as as post step when running typings install.. :(

This issue has been around for years. I've removed the protractor typings for now but will do this as a post install step to fix it ..

@kschio
Copy link

kschio commented Mar 30, 2016

@samvloeberghs I agree, that's why I stated that this is not a clean solution but I didn't find the time to provide something yet.

Let me know if you work on this or if I can help you out.

@smitalm
Copy link

smitalm commented Oct 4, 2016

this is not a good approach, as anyone(including you) who will get the code and install it on some other workstation will not have this change. It's something you need to remember or put as as post step when running typings install.. :(

This issue has been around for years. I've removed the protractor typings for now but will do this as a post install step to fix it ..

If i uninstall protractor typings, i just get another error:
Cannot find type definition file for 'protractor'.
How can i make this go away?

@smitalm
Copy link

smitalm commented Oct 4, 2016

If i uninstall protractor typings, i just get another error:
Cannot find type definition file for 'protractor'.
How can i make this go away?

Ok i just had to remove "protractor" from tsconfig.json types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants