Add support for non-ambient TypeScript module generation in ssutil
While having typing information in an ambient module (d.ts) is great for most use cases it doesn't cover the following two problems:
- Using enums declared in an ambient module: The enums are not compiled to JavaScript objects and can therefore not be used
- Creating instances of DTOs: You cannot create an instance of a DTO if it is an interface.
My suggestion is to have the possibility to create a normal TypeScript module with classes instead of interfaces and exported enums which can be compiled to JavaScript.
Currently the following ambient module is created
declare module api
{
interface MyDTO
{
foo: string;
bar: MyEnum;
}
enum MyEnum
{
foo,
bar,
baz,
}
This is what should be possible to create:
module api
{
export class MyDTO
{
foo: string;
bar: MyEnum;
}
export const enum MyEnum
{
foo,
bar,
baz,
}
This is what we currently want to do, but are not able to:
class Foo
{
constructor()
{
var dto = new MyDTO(); // not possible because MyDTO is an interface
dto.bar = MyEnum.foo; // not possible because MyEnum is not compiled to a JavaScript object
}
}

Since this seems to be a popular option we’ve added a friendlier url to enable this option:
TypeScript module:
http://test.servicestack.net/types/typescript
Definition file:
http://test.servicestack.net/types/typescript.d
We’ve also added an index containing links to all the supported languages at:
http://test.servicestack.net/types
-
Tobias Zürcher commented
thank you very much for the fast implementation! keep going (or better sprinting ;))