Definitelytyped: @types/angular are incompatible with the latest version of @types/jquery

Created on 19 Jun 2017  路  13Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/angular package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [ ] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

Please specify old version for jquery typings in dependencies, I think it should be 2.0.47

All 13 comments

Same for types/chart.js

Could you guys elaborate on how they're incompatible?

@leonard-thieu for chart.js, the compilation fails with hundreds of "generic type request x arguments" errors.

@ruffiem could you post a repro? Other users have reported something similar but the error messages reported don't make sense. I'm really interested in figuring out why this is happening.

@leonard-thieu I'm suddenly getting a failing tsc on my build. If it's helpful, my build succeeds when using npm@5 and my lockfile, but breaks using an older npm that ignores my lockfile.

Both use [email protected].

Working tsc: @types/[email protected], @types/[email protected].
Failing tsc: @[email protected], @types/[email protected].

Error message:

node_modules/@types/jquery/index.d.ts(2362,84): error TS2304: Cannot find name 'Iterable'.

tsconfig.json

{
  "compilerOptions": {
    "module": "es6",
    "sourceMap": true
  },
  "exclude": [
    "node_modules",
    "**/*.spec.ts"
  ]
}

Unfortunately my build server doesn't support npm@5 yet so this is painful.


edited to add typescript version info and my tsconfig.json

@menzer

This happens if you're targeting es5. You'll need to add es2015.iterable to your lib in tsconfig.json.

        "lib": [
            "dom",
            "es5",
            "scripthost",
            "es2015.iterable"
        ],
        "target": "es5",

Alternatively, you just change your target to es6.

@leonard-thieu That it worked before and doesn't now due to a minor version bump of @types/angular containing a major version bump of @types/jquery as a secondary dependency for me seems counter to proper semver...

@menzer @types packages don't follow semver. They track the MAJOR.MINOR version of the package they declare types for. @types/angular probably shouldn't even be declaring a dependency on @types/jquery given that AngularJS doesn't have a hard dependency on jQuery.

If you don't want to take the major version bump, you can add "@types/jquery": "<2.2" to your package.json.

@types/angular probably shouldn't even be declaring a dependency on @types/jquery given that AngularJS doesn't have a hard dependency on jQuery.

@leonard-thieu I would agree, this might help prevent this issue in the future. I was certainly surprised to find out that I had jQuery types in my project, as I don't use jQuery (or even any JQlite) in my project. If that's the versioning pattern, that's definitely incompatible with including a dependency on another @types package, especially if it's versioned at *.

@leonard-thieu I use angular 1.6.1 and typescript 2.2.2 with @types/angular 1.6.1
several days ago my build permanently failed, the same as described @ruffiem
So I added @types/jquery: "2.0.47" to my package.json as temporarily fix, but I don't use JQuery at all, so I don't want to have its typings in my dependencies
Probably it is better to add package.json

{
  "dependencies": {
    "@types/jquery": "<2.2"
  }
}

to @types/angular or remove reference to jquery typings from there

I'm working on removing the dependency on @types/jquery from @types/angular (https://github.com/leonard-thieu/DefinitelyTyped/pull/3). I'll be putting in a PR soon.

nice, thank you

@ruffiem If you still have your error, you'll probably fix it by upgrading typescript version.
I had the same errors as you had, with many errors "generic type request x arguments", and I upgraded typescript from ~2.0.3 to ~2.3.0

Then you can import Chart JS wherever you want

import * as Chart from 'chart.js';

And use it as explained in documentation

var canvas = <HTMLCanvasElement> document.getElementById("chart");
var ctx = canvas.getContext("2d");
var myChart = new Chart(ctx, config);
Was this page helpful?
0 / 5 - 0 ratings