How do you generate a single file containing the parent class and all child classes?

104 Views Asked by At

I've currently got a tst that generates the parent class, but the child classes need to be listed separately in the file as well so that I end up with 1 file that contains all necessary files for the front end.

key parts of the tst look like this at the moment:

$Imports

$Classes([TsType])[
export interface $Name $Extends {
    $Properties(o=>o.Attributes.Any(a=>a.Name=="TsIgnore")==false)[
    $name$IfOptional: $TypeNamespace$Type;]
}]

$Classes(*Generic)[
class $Name$TypeParameters { 
$Properties[
    public $name: $Type;]
}]

$Enums([TsType])[
export enum $Name{
$Values[
$name,
]
}
]
1

There are 1 best solutions below

0
flayn On

In the $Classes you can access the $NestedClasses. See here: http://frhagn.github.io/Typewriter/pages/documentation.html

$Classes(*Generic)[
class $Name$TypeParameters { 
$Properties[
    public $name: $Type;]
$NestedClasses(*Generic)[
   class $Name$TypeParameters { 
   $Properties[
       public $name: $Type;]
}]

}]