I suggest you ...

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
}
}

11 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Michael ZöllnerMichael Zöllner shared this idea  ·   ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Tobias ZürcherTobias Zürcher commented  · 

        thank you very much for the fast implementation! keep going (or better sprinting ;))

      Feedback and Knowledge Base