Why does this declaration file babylon.d.ts have multiple declarations of the module BABYLON?

I was going through the documentation and was looking at this declaration file: https://preview.babylonjs.com/babylon.d.ts

Why is the BABYLON module declared multiple times. Are these overloads or something?

Historically we had to build the d.ts file this way. As it is perfectly acceptable by typescript, and is only used during development, we will probably keep it this way for now.

Do you have any technical issue with it, or are you just asking why it was done this way?

No, I was just asking why it was done this way. After looking at some other TypeScript declaration file examples, I guess these are just overloads.

On second thought, are these overloads, though? There are 793 instances of declare module BABYLON in the file.

TypeScript 0.9 (or even 1), didn’t have the tools to build a single d.ts file for the whole project, so what we did was merge all d.ts files into one, and provide it as is. This is perfectly “legal” in the typescript world (and can be used for mixins). There are 793 instances of declare module, because there are 793 .ts files in the repository (dunno, i didn’t count, but it makes sense somehow).

I hope this answers your question!

That makes sense. Thanks for the info!