The Issue at Hand
Given an existing application with a mixture of modules and global scripts, the goal is to convert one class in a global script (gamma.ts) into a module. This entails adding `export default` before `class gamma {}` in gamma.ts. Additionally, the objective is to import the gamma class into the global namespace (window object) for accessibility by both global and module scripts.
Approaches Taken So Far
Several attempts have been made involving global.d.ts file.
For instance:
import gammaAlias from "../scripts/gamma";
export as namespace NS_Global;
declare global {
var qqq: {n:string};
namespace ZZZ {
export var gamma: gammaAlias;
}
var gamma: gammaAlias;
}
Despite these efforts, TypeScript has thrown errors such as "gamma does not exist" or "Cannot use 'new' with an expression whose type lacks a call or construct signature."
Exploring on GitHub
To delve deeper into this issue, check out my GitHub repository: https://github.com/penguin020/expose-typescript-modules-globally
The ConvertToModulesPOC_original represents the functional "before" scenario.
In contrast, ConvertToModulesPOC signifies an unsuccessful effort to convert gamma .ts to a module and expose it globally.
Final Notes
The core question remains - how can a module be exposed to the global namespace? Any insights utilizing the provided examples in the GitHub repository would be highly appreciated!