@@ -89,6 +89,8 @@ type TypeScriptify struct {
8989 CreateInterface bool
9090 CustomJsonTag string
9191 customImports []string
92+ customCodeBefore []string
93+ customCodeAfter []string
9294 silent bool
9395
9496 structTypes []StructType
@@ -352,6 +354,14 @@ func (t *TypeScriptify) Convert(customCode map[string]string) (string, error) {
352354 }
353355 }
354356
357+ if len (t .customCodeBefore ) > 0 {
358+ result += "\n "
359+ for _ , code := range t .customCodeBefore {
360+ result += "\n " + code + "\n "
361+ }
362+ result += "\n "
363+ }
364+
355365 for _ , enumTyp := range t .enumTypes {
356366 elements := t .enums [enumTyp .Type ]
357367 typeScriptCode , err := t .convertEnum (depth , enumTyp .Type , elements )
@@ -368,6 +378,15 @@ func (t *TypeScriptify) Convert(customCode map[string]string) (string, error) {
368378 }
369379 result += "\n " + strings .Trim (typeScriptCode , " " + t .Indent + "\r \n " )
370380 }
381+
382+ if len (t .customCodeAfter ) > 0 {
383+ result += "\n "
384+ for _ , code := range t .customCodeAfter {
385+ result += "\n " + code + "\n "
386+ }
387+ result += "\n "
388+ }
389+
371390 return result , nil
372391}
373392
@@ -747,6 +766,14 @@ func (t *TypeScriptify) AddImport(i string) {
747766 t .customImports = append (t .customImports , i )
748767}
749768
769+ func (t * TypeScriptify ) WithCustomCodeBefore (i string ) {
770+ t .customCodeBefore = append (t .customCodeBefore , i )
771+ }
772+
773+ func (t * TypeScriptify ) WithCustomCodeAfter (i string ) {
774+ t .customCodeAfter = append (t .customCodeAfter , i )
775+ }
776+
750777type typeScriptClassBuilder struct {
751778 types map [reflect.Kind ]string
752779 indent string
0 commit comments