If you write a module, you'll end up with nearly identical code...
module ToggleSwitch {
}
Modules can be extended in TypeScript. The only difference is the compiler will know whether the module is already declared or not, which saves you the test.
To take this example further, here is an example with ToggleSwitch declared twice, with different contents. You'll notice that you can access all the contents. This can be split across multiple files:
module ToggleSwitch {
export class a {
go() {
alert('a');
}
}
}
module ToggleSwitch {
export class b {
go() {
alert('b');
}
}
}
var a = new ToggleSwitch.a();
var b = new ToggleSwitch.b();
a.go();
b.go();