Skip to content

Error on $ in angular-protractor.d.ts #4725

Closed

Description

@basvandenheuvel

Hi,

I'm getting an error on

declare var $: cssSelectorHelper; 

in the angular-protractor.d.ts of angular alpha 42.
( I just upgraded from .37 to .42, so i don't know if this problem is there since 38.. 39 .. 40...)

I think it conflicts with the jquery.d.ts which exports the $.

I'm using VisualStudio 2015. The error i get is Build: Subsequent variable declarations must have the same type. Variable '$' must be of type 'JQueryStatic', but here has type 'cssSelectorHelper'.

Does anyone have a solution? Commenting the line seems like a workaround but doesn't feel right.

Activity

  1. jessegood commented on Oct 14, 2015

    @jessegood

    @basvandenheuvel : See #4507. Sorry I don't know the solution for Visual Studio though.

  2. basvandenheuvel commented on Oct 15, 2015

    @basvandenheuvel
    Author

    Thanks, I indeed wasn't able to solve this problem in VS. I just commented the line in the .d.ts file...

  3. DennisRoam commented on Oct 23, 2015

    @DennisRoam

    What is the "correct" way around this issue? I'm using the angular2 seed but added jQuery to run third party scripts and I'm hitting this issue. Commenting out is fine for now but is very hacky..

  4. basvandenheuvel commented on Oct 23, 2015

    @basvandenheuvel
    Author

    @DennisRoam They closed the issue without giving any kind of solution, sorry. At the moment i just comment the line.... The problem is if you run npm update or npm install, the file is downloaded again and you have to comment the line again. I don't understand why angular would declare a var named $ since thats JQuery's for the past years

  5. mbalex99 commented on Nov 22, 2015

    @mbalex99

    +1 I did the hack that @basvandenheuvel said

  6. vladimir-ivanov commented on Dec 2, 2015

    @vladimir-ivanov

    as a workaround, since jquery does not distribute a jquery.d.ts file, the file definition of jquery.d.ts could be placed in [source-code-base-dir]/typings/jquery.d.ts
    and simply change the bottom lines to:
    declare module "jquery" {
    export var $:JQueryStatic;
    }
    //declare var jQuery: JQueryStatic;
    //declare var $: JQueryStatic;

    or declare a new module as such (a bit hacky):
    declare module "jquery" {
    export var $:any;
    }
    and the error will go away (tested with webpack and ts-loader)

    I personally think this is not a problem with angular2 d.ts files and more likely incorrect import of jquery.

  7. devcube commented on Dec 10, 2015

    @devcube

    Hmm, well I'm not convinced. As @basvandenheuvel said, $ has belonged to jQuery for quite some time. I'm also having this problem and I'm hoping for a more permanent solution than to keep commenting the line in angular2 (or changing the jquery.d.ts file).

  8. htakemoto commented on Feb 1, 2016

    @htakemoto

    I had the same issue with $.
    I downloaded beta2 of angular2, and it worked fine.

  9. tonyeung commented on Apr 14, 2016

    @tonyeung

    @vladimir-ivanov's solution works

  10. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  11. locked and limited conversation to collaborators on Sep 8, 2019
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions