Skip to content

Type definition conflict with jQuery TSD #5459

Closed

Description

@teropa

When trying to compile a TypeScript file that imports something from angular2 (2.0.0-alpha.46) and also references the TSD type definitions for jQuery, I get the following error from the TypeScript compiler:

node_modules/angular2/typings/angular-protractor/angular-protractor.d.ts(1679,13): error TS2403:
Subsequent variable declarations must have the same type.  Variable '$' must be of type
'JQueryStatic', but here has type 'cssSelectorHelper'.

The app itself doe not refer to Protractor in any way. The types are pulled in by Angular 2 internally, it seems.

Use case: Running a hybrid Angular 1+2 app during upgrade. The Angular 1 type definitions from TSD also pull in jQuery type definitions, and I suspect they'll be commonly used during upgrades.

Minimal repo that reproduces the problem: https://github.com/teropa/ng2-jquery-type-conflict

Suggested fix: Don't include Protractor type definitions unless the user asks for them?

Activity

  1. dsebastien commented on Nov 24, 2015

    @dsebastien

    There's a common theme here: #5395 :)

  2. ericmartinezr commented on Nov 24, 2015

    @ericmartinezr
    Contributor

    There's another issue related #4725

  3. PatrickJS commented on Nov 24, 2015

    @PatrickJS
    Contributor

    typings fixes this (the TSD replacement)
    related The State of Typescript Packages

  4. dsebastien commented on Nov 24, 2015

    @dsebastien

    Thanks for the links @gdi2290, I'll check that out! There's indeed still room for improvement in TS typings land ;-)

  5. geyang commented on Nov 25, 2015

    @geyang

    @gdi2290 I tried to install jquery and angular2 using typings. DId this just came out today?

  6. blakeembrey commented on Nov 25, 2015

    @blakeembrey

    @episodeyang Those typings are not in the registry. If you would like to create them and contribute them to the registry, you're welcome to! You should have seen this message when you tried to use it:

    ➜  typings git:(master) typings i angular -S
    TypeError: Unable to find "angular" from "npm" in the registry. If you can contribute this typing, please help us out - https://github.com/typings/registry
    
  7. yizhan commented on Dec 4, 2015

    @yizhan

    I had the same problem when i upgrade angular. We do not use angular-protractor.d.ts, but it has been added in there when import as angular/angular. Is angular-protractor compulsory?

    I tried to comment angular-protractor.d.ts out which also fix this problem. That would not be a solution, because it is a part of package.

    In the end, I have to commented

    declare module "jquery" {
        export = $;
    }
    
    declare var $: JQueryStatic;
    
  8. geyang commented on Dec 4, 2015

    @geyang

    Hi, this problem still persists in alpha.47.

  9. demurgos commented on Dec 10, 2015

    @demurgos

    Thank you @gdi2290, typings seems really promising. It would be great if angular's definition would not leak as described in the article.

  10. lacolaco commented on Jan 2, 2016

    @lacolaco
    Contributor

    I have the same problem in angular2-beta.0 and angularjs-1.4.8

  11. lacolaco commented on Jan 21, 2016

    @lacolaco
    Contributor

    @IgorMinar Hi, what do you think this? Due to this, I cannot do a migration from ng1 to ng2.

  12. self-assigned this
    on Jan 21, 2016
  13. PatrickJS commented on Jan 21, 2016

    @PatrickJS
    Contributor

    @laco0416 you should switch to typings. I recommend deleing the types in the angular2 repo and manage it with typings outside. You should also have a config for each environment. For an example see angular/universal-starter@cfb7b52

  14. IgorMinar commented on Jan 22, 2016

    @IgorMinar
    Contributor

    We are working on resolving this. Part of the solution landed already:
    #6262

    The final part of the solution is in works now.

    On Wed, Jan 20, 2016 at 8:40 PM PatrickJS [email protected] wrote:

    @laco0416 https://github.com/laco0416 you should switch to typings. I
    recommend deleing the types in the angular2 repo and manage it with
    typings outside. You should also have a config for each environment. For
    an example see angular/universal-starter@cfb7b52
    angular/universal-starter@cfb7b52

    —
    Reply to this email directly or view it on GitHub
    #5459 (comment).

  15. NikGovorov commented on Jan 29, 2016

    @NikGovorov

    It works in beta2.

  16. alexeagle commented on Feb 12, 2016

    @alexeagle
    Contributor

    I believe this is fixed. Note that angular-protractor.d.ts and jquery.d.ts still conflict on the definition of $, see DefinitelyTyped/DefinitelyTyped#2734

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

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

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