To extend TypeScript Global object in node.js, we add a type declaration file.
For instance, we write
declare module NodeJS {
interface Global {
spotConfig: any;
}
}
to add a type declaration in vendor.d.ts to add the Global
interface into the project type definition with the properties we want to add to the global interface.
Therefore, we can use the spotConfig
global variable without type errors.