Definitelytyped: Node Typing Typescript Compile error, TS2304: Cannot find name 'IterableIterator'.

Created on 30 Aug 2016  Â·  21Comments  Â·  Source: DefinitelyTyped/DefinitelyTyped

Using the latest Node Definition file #6.0.0+20160830141956, the compiler throws a Typescript Compile error, TS2304: Cannot find name 'IterableIterator'. It is coming from a deprecated NodeBuffer method (It appears in there 3 times). Is there another typing file I'm missing, or is this an issue?

Most helpful comment

This is because of the latest update to node.d.ts and is breaking builds that use ES5 flag in tsc. Can this be fixed asap?

All 21 comments

I found the reference, however I'm not sure if it should be a required thing or not. The IterableIterator is in the core-js typing. My Web API backend does not use core-js so it was failing, however my Front End web app (an Angular 2 app) uses it.

This is because of the latest update to node.d.ts and is breaking builds that use ES5 flag in tsc. Can this be fixed asap?

image
image

I submitted the pull request. @hewholived I'm sorry for the inconvenience but I believe it to be a fair change, sice the node.d.ts addresses node v6 and v6 supports 99% of es 2015. However, maybe a reference to es6-shim needs to be included in node.d.ts itself? @vvakame @rbuckton

I would not add a reference to es6-shim. Rather, you can add an empty IterableIterator<T> interface as a forward declaration. The empty interface will merge with the definition in lib.es6.d.ts. The node.d.ts file does the same thing with MapConstructor.

I have the same problem.
It happened because - I use express.d
express.d use it - /// <reference path="../express-serve-static-core/express-serve-static-core.d.ts" />
express-serve-static-core.d use it -/// <reference path="../node/node.d.ts" />
node.d it is a v6. but express.d is a v4 and they aren't compatible. If I use node-4.d - it works fine but I should rename manual from node-4.d to node.d
Can you fix it?

Thanks @rbuckton

Thanks @alejo90 @rbuckton for the patch. LGTM. Looking forward to seeing it merged into master.

Afraid the proposed fix in PR #10943 isn't complete. Due to the tricky situation, I've prepared a PR #10967 to complete roll-back the change that introduced this. If #10943 can be fixed, that's OK.

To be clear, I think the root problem is that in Node 6, ES2015 is an opt-in compatibility, and not everyone is ready to opt-in. @vvakame was the committer, perhaps he should review.

@BurtHarris thanks for the more thorough testing. I agree, it's worrying that the project wide npm test doesn't catch the issue. I tested it locally as you mentioned and I was able to fix it by making IterableIterator<T> extend Array<T>. I verified that it works when targetting es2015 too and pushed the fix.

I'm receiving this error with the whatwg-fetch types with TypeScript Version 2.0.2

{
  "name": "my-app",
  "globalDevDependencies": {
    "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
    "whatwg-fetch": "registry:dt/whatwg-fetch#0.0.0+20160829180742"
  }
}
typings/globals/whatwg-fetch/index.d.ts(19,16): error TS2304: Cannot find name 'IterableIterator'.
typings/globals/whatwg-fetch/index.d.ts(21,13): error TS2304: Cannot find name 'IterableIterator'.
typings/globals/whatwg-fetch/index.d.ts(22,15): error TS2304: Cannot find name 'IterableIterator'.
typings/globals/whatwg-fetch/index.d.ts(23,6): error TS2304: Cannot find name 'Symbol'.
typings/globals/whatwg-fetch/index.d.ts(23,26): error TS2304: Cannot find name 'IterableIterator'.
typings/globals/whatwg-fetch/index.d.ts(88,11): error TS2304: Cannot find name 'ReadableStream'.

@shaunluttin I think your issue may be unrelated to this one because this is specific to node.d.ts.

@digital216 could you please change the issue name to mention that it's about node.d.ts?

Done!

On Thu, Sep 1, 2016 at 3:52 PM Alejandro Sánchez [email protected]
wrote:

@shaunluttin https://github.com/shaunluttin I think your issue may be
unrelated to this one because this is specific to node.d.ts.

@digital216 https://github.com/digital216 could you please change the
issue name to mention that it's about node.d.ts?

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/10919#issuecomment-244208385,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AK5k5pCfS9ZKKbwY7PINvj2nmZ9qweNcks5qlzrggaJpZM4Jw0e8
.

@shaunluttin, while your issue is similar, it probably deserves a separate bug tracking it because the fix will need to go in a different directory/file, and the errors re Symbol and ReadableStream have different shim solutions. Also please include for your case the intended target environment, (browser or node?)

@BurtHarris I found a fix. Would you still like me to create a new issue?

Fix:

.\node_modules\.bin\typings install --save --global dt~core-js

Thanks, no probably not. Did that take care of the reference to ReadableStream? I don't see it mentioned in that file.

wow, sorry for late. thank you @alejo90 !

@BurtHarris ReadableStream is defined in whatwg-streams:

`typings install dt~whatwg-streams --global --save`

@digital216 hi there!

I have the same error, but after that command:

typings install dt~node --save-dev --global

situation was clear.

So now what?

I still have this error, and i don't think i want to run that command on all my projects on the buildserver..
(and i don't like globals anyway)

How about the after-install script of typedoc executes that command (not global)?

Just catching up on this, and I've learned more about WHATWG streams in the mean time.

@Basie, npm install @types/whatwg-streams --save-dev should probably take care of this for you.

Was this page helpful?
0 / 5 - 0 ratings