Definitelytyped: @types/[email protected] Map and Set missing

Created on 17 May 2017  路  10Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/xxxx 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).
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @nicojs

The addition by @nicojs causes the following errors that were not present in 2.2.1:

(389,30): error TS2304: Cannot find name 'Map'.
(393,28): error TS2304: Cannot find name 'Map'.
(400,30): error TS2304: Cannot find name 'Set'.
(404,28): error TS2304: Cannot find name 'Set'.

reverting to version 2.2.1 removes these errors.

Most helpful comment

npm install --save-dev @types/es6-collections

Seems to have fixed it.

All 10 comments

8264 might hold the answer. For those not using ES6 something like the following would need to be added:

interface Map<v, k> {}
interface Set<T> {}

Why not use the "lib" option in tsconfig.json?

{
  "compilerOptions": {
    "lib": [
      "dom",
      "es2015"
    ],

@aluanhaddad when you're not building a browser app for example

We should add the interfaces. @Jraller do you want to prepare a PR?

I only added "dom" as an example. If you are targeting NodeJS you can still use "lib": ["es2015" to get Set and Map and whatnot.

Ah ok, yeah than that would be better.

Does that mean this version of sinon does not support older versions of node where there is no Map and Set? If no, than we should still add the interfaces.

lib: ["dom"] is not enough if you are targeting es5 if I am not mistaken. Since the types are shimed in Sinon, there should be an interface for them in Sinon IMHO. Unless there is something that I did not get right.

@jraller your suggestion worked for me. I've raised a PR but I get the feeling there might be a deeper issue.

npm install --save-dev @types/es6-collections

Seems to have fixed it.

npm install --save-dev @types/es6-collections` 

Seems to have fixed it.

Although this is true, i would prefer to use the bundled es6.collections lib. In tsconfig:

"lib": [
          "es2015.collection"
]

NB: You might also need other libs, like "es5" and "dom"

Thanks @nicojs. I've got it to work with:

"lib": ["es5", "es2015.collection", "es2015.promise"]
Was this page helpful?
0 / 5 - 0 ratings