I maintain a TS app using Node's cluster
API that built fine with Node 14.x and Node 14.x cluster
types from DT.
As I move this app to Node 16.x, I bumped @types/node
from 14.x
to 16.x
, and then TS fails to compile:
import cluster from 'cluster';
...import * as cluster from 'cluster';
(no default import)At that point,
import * as ...
non-default imports, I have to add a bunch of // @ts-expect-error
to be able to compile, and my app works.ā What am I supposed to do? I'm asking here before filing a bug on DT, because I understand I'm possibly in a weird place because DT seems to be moving to ESM, and I'm still using TS with commonjs
(my tsconfig has "module": "commonjs", "moduleResolution": "node"
).
... but if I try to add an "esModuleInterop": true
to my tsconfig, then I get a zillion other errors from various dependencies (this is a large app).
The problem is reproducible with cluster.d.ts' example at the top of the file. Here's a TS Playground link.
ā Outcomes:
cluster
the only Node built-in module that exhibits the issue? (I'm still very much able to import * as process from 'process';
or import * as os from 'os';
for example!)Well, this is a bug. I found two DT discussions that confirm the issue: 1, 2.
Hadn't found them before writing this StackOverflow post because I was looking in DT Issues, but somehow they switched to Discussions.