0

What's the correct way to use typeof globalThis? No shortcuts please.

interface CustomNodeJsGlobal extends NodeJS.Global {
  foo: {
    bar: string | null
  }
}

This obviously will give: Namespace 'NodeJS' has no exported member 'Global'.ts(2694)

1 Answers1

0

For node.js 16.x, adding below should work.

declare global {
  namespace NodeJS {
    interface Global {}
  }
}

For node.js <16, we can install @types/node package npm i @types/node@^14 or npm i @types/node@^15 etc.,

bhanu.dev
  • 76
  • 4