tkrajina / typescriptify-golang-structs

A Golang struct to TypeScript class/interface converter
Apache License 2.0
505 stars 87 forks source link

Struct Array Alias #59

Open przemeklach opened 2 years ago

przemeklach commented 2 years ago

Hi,

Given a struct:

type DeviceListing struct {
    Identifier        string    `json:"identifier"`
    AccountIdentifier string    `json:"accountIdentifier"`
    ContactEmail      string    `json:"contactEmail"`
}

I create two other alias structs:

type CreateListingResponse DeviceListing

type GetDeviceListingsResponse []DeviceListing

The CreateListingResponse Typescript interface is created correctly; however, for GetDeviceListingsResponse it just outputs:

export interface GetDeviceListingsResponse {

}
mozey commented 1 year ago

As per the README: "Only fields with a valid json tag will be converted to TypeScript models"

So you have to declare the list type like this

type GetDeviceListingsResponse struct {
  DeviceListing []DeviceListing `json:"deviceListing"`
}