Typescript error: Map.values() giving IterableIterator not Iterable

后端 未结 1 510
梦谈多话
梦谈多话 2021-01-12 08:22

Typescript is giving me this error when I try to iterate over the value returned from Map.values() (where the Map has type ):

相关标签:
1条回答
  • 2021-01-12 09:02

    I wasn't understanding some of the implicit stuff tsc is doing rel the tsconfig.json. Reading tsconfig.json doc made things clearer:

    First, I was transpiling like this tsc mytypescript.ts which (stupidly) causes Typescript to silently ignore tsconfig.json file, which meant it was using the default ES5. But this was partially working because tsc was still finding the core-js declarations which contain declaration for ES6 things like Map, Iterable etc. That threw my debugging a bit.

    Second, after getting Typescript to actually pick up my config, the config was wrong anyway. I don't actually need or want those declarations from @types/core-js (pretty sure). Yes, I'll use core-js as a polyfill in my project, but Typescript comes with it's own declarations for ES6 stuff in typescript/lib/lib.es6.d.ts, and the ones in @types/core-js are old weird and crappy or something ...

    0 讨论(0)
提交回复
热议问题