I'm imported clusters as
import * as cluster from "cluster";
and when I'm trying to check cluster.isMaster in if(cluster.isMaster){} I'm getting this error
TS2339: Property 'isMaster' does not exist on type 'typeof import("cluster")'.
and
import cluster from "cluster";
I'm getting that cluster is undefined.
How can I solve the problem in ts, how can I import clusters in ts and use them?
I have got the same issue today, and this workaround worked for me:
import * as _cluster from 'cluster';
const cluster = _cluster as unknown as _cluster.Cluster; // typings fix
I faced the same issue today and solved it by setting "esModuleInterop": true in tsconfig.json.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With