tkrajina/typescriptify-golang-structs

Documentation comments

harnyk opened this issue · 3 comments

I would like if the following struct:

// Header Item
type HeaderItem struct {
	//Header name
	Name  string `json:"name"`
	//Header value
	Value string `json:"value"`
}

would convert to the following interface

/**
 * Header Item
 */
interface HeaderItem {
   /**
    * Header name
    */
   name: string;

   /**
    * Header value
    */
   value: string;
}

Is it possible? Other option would be to have a special tag:

type HeaderItem struct {
	Name  string `json:"name" doc:"Header name"`
	Value string `json:"value" doc:"Header value"`
        _ struct{} `doc:"Header Item"`
}

This library won't be able to support this as it's reflection based, you could consider using tygo instead.

You make it sound like "reflection based" is something very bad @gzuidhof :) "Parser based" solves some problems but introduces others (for example - how about inner structs or structs in multiple packages).

Anyway... Adding a tag for specifying typescript comments is simple to implement @harnyk .