0

I am using a global variable job_name. I will set the value for this variable in file1.ts. I would like to use the global variable in file2.ts. However, in file2.ts, job_name is undefined though I am setting in file1.ts. Seems like since file1 and file2 are loaded as soon as project is initiated (even before job_name is set in file1), file2 is assuming a value of undefined for job_name. Please let me know how I can use job_name in file2.ts with the value set in file1.ts.

global.d.ts
declare global {
  var job_name: any
}   

export { };

Extra info for reference: Original question (this is my actual scenario) - Global variable for 'log' in other files is undefined since it is set after project is started in nodejs

Pavan Kumar
  • 129
  • 7

0 Answers0