Node.js 22 has just hit LTS, bringing with it some additional goodies like support for Iterator.toArray and Iterator.map.
We're also no longer constrained to Node 20, since Cloudflare has confirmed that using their codegen for types (which we are) means we do not need to pin the @types/node package to v20, so we can actually upgrade to Node 22.
Context
This will be useful in cleaning up components of our data pipelines, since we use the following pattern a lot:
const theMap = new Map<string, unknown>();
const res = Array.from(theMap.keys()).map((key) => { ... });
Which can then be converted into this pattern:
const theMap = new Map<string, unknown>();
// toArray can even be omitted in cases where the function consuming res accepts an Iterator
const res = theMap.keys().map((key) => { ... }).toArray();
Node.js 22 has just hit LTS, bringing with it some additional goodies like support for
Iterator.toArray
andIterator.map
.We're also no longer constrained to Node 20, since Cloudflare has confirmed that using their codegen for types (which we are) means we do not need to pin the
@types/node
package to v20, so we can actually upgrade to Node 22.Context
This will be useful in cleaning up components of our data pipelines, since we use the following pattern a lot:
Which can then be converted into this pattern:
Action Items
.nvmrc
to 22.11.0@types/node
at workspace level@types/node
at package levelArray.from