Skip to content

Jquery error  #435

Description

@liu-kanghui

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!!!!

Activity

  1. kschio commented on Mar 19, 2016

    @kschio

    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.

  2. sergiomedinavalentin commented on Mar 21, 2016

    @sergiomedinavalentin

    @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

  3. samvloeberghs commented on Mar 23, 2016

    @samvloeberghs
    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 ..

  4. kschio commented on Mar 30, 2016

    @kschio

    @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.

  5. smitalm commented on Oct 4, 2016

    @smitalm

    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?

  6. smitalm commented on Oct 4, 2016

    @smitalm

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions