Closed shackra closed 3 years ago
I pushed another branch debug-logging
. With it you can add some additional debug logging by setting converter.Debug = true
. With that, you'll get the fields which cause the converter to create new models, for example:
Converting struct typescriptify.TestCustomType
Struct TestCustomType.Time (time.Time) => convert
So here, the Test
field in TestCustomType
is causing a new Time
class/interface to be created. Then, find which field is causing the empty Time
, and try to write a minimal reproducible test with that struct.
Also, add this:
converter.AddImport("type Decimal = number;") // Not an import, I know :)
in your TestAnonymousStructWithManagedType
not make the generated script to compile (and the test to finish without errors).
I use Go modules in my project, to use your branch I need to clone the repository in vendors/
maybe? I'll try to figure that out tonight
Yes, you can clone it temporary. But you can also:
go get github.com/tkrajina/typescriptify-golang-structs@ddc6a2f51e3cde9d0c1dae7b9f3e50b433f6e9d3
go mod vendor
ddc6a2f51e3cde9d0c1dae7b9f3e50b433f6e9d3 is the last commit in debug-logging
. Or, you can specify a branch:
go get github.com/tkrajina/typescriptify-golang-structs@debug-logging
go mod vendor
I get the following:
Converting struct http_transport.UpdateInvoicesRequest
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.InvoiceCreateRequest
Struct InvoiceCreateRequest.Receptor (service.Receptor) => convert
Converting struct service.Receptor
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Struct InvoiceCreateRequest.LineaDetalle ([]service.LineaDetalle) => convert
Converting struct service.LineaDetalle
Struct LineaDetalle.CodigosComerciales ([]service.CodigoComercial) => convert
Converting struct service.CodigoComercial
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Struct LineaDetalle.Impuesto ([]service.Impuesto) => convert
Converting struct service.Impuesto
Struct Impuesto.Exoneracion (service.Exoneracion) => convert
Converting struct service.Exoneracion
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Struct InvoiceCreateRequest.OtrosCargos ([]service.OtroCargo) => convert
Converting struct service.OtroCargo
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Struct InvoiceCreateRequest.InformacionReferencia ([]service.InformacionReferencia) => convert
Converting struct service.InformacionReferencia
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.UpdatePasswordRequest
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.RefreshTokenRequest
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.CredentialsRequest
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.PasswordResetRequest
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.ForwardInvoiceTo
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.GetCountersResp
Struct GetCountersResp.Consecutivos ([]service.Consecutivo) => convert
Converting struct service.Consecutivo
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.SearchIssuersResp
Struct SearchIssuersResp.Issuers ([]service.Emisor) => convert
Converting struct service.Emisor
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.UpdateCounterReq
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.UpdateIssuerInfoReq
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.UpdateIssuerLocationReq
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.CreateSubscriptionReq
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.SubscriptionIsDueResponse
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.ListSubscriptionsResponse
Struct ListSubscriptionsResponse.Suscripciones ([]service.Subscription) => convert
Converting struct service.Subscription
Struct Subscription.Costo (decimal.Decimal) => convert
Converting struct decimal.Decimal
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Struct Subscription.Adicional (decimal.Decimal) => convert
Converting struct decimal.Decimal
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.UpdateSubscriptionPrice
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct http_transport.UpdateSubscriptionStatus
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct json_web_token.Token
Struct Token.ExpirationTime (jwt.Time) => convert
Converting struct jwt.Time
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Struct Token.NotBefore (jwt.Time) => convert
Converting struct jwt.Time
Struct Token.IssuedAt (jwt.Time) => convert
Converting struct jwt.Time
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct service.Documento
Struct Documento.Emisor (service.Emisor) => convert
Converting struct service.Emisor
Struct Documento.Receptor (service.Receptor) => convert
Converting struct service.Receptor
Struct Documento.FormaPago ([]service.FormaPago) => convert
Converting struct service.FormaPago
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Struct Documento.LineaDetalle ([]service.LineaDetalle) => convert
Converting struct service.LineaDetalle
Struct Documento.OtrosCargos ([]service.OtroCargo) => convert
Converting struct service.OtroCargo
Struct Documento.InformacionReferencia ([]service.InformacionReferencia) => convert
Converting struct service.InformacionReferencia
Struct Documento.Resumenes (service.Resumen) => convert
Converting struct service.Resumen
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
Converting struct service.Tokens
FromMethod METHOD IS DEPRECATED AND WILL BE REMOVED!!!!!!
I think I can see the offender
Converting struct service.Subscription
Struct Subscription.Costo (decimal.Decimal) => convert
Converting struct decimal.Decimal
Indeed, there is no bug, there was another struct called Time
that needed to be managed, and I was missing tags in some of my structs too.
so I
get
'd the new version of this package and generate a few more types for my project, but for some reasons empty interfaces likeTime
andDecimal
(that one was new) were getting generated despite havingts_type
set on some fields of some structs and also using the new feature you recently merged and polished.This is the generated file:
and this is the Golang file:
I want through each struct there and checked that each field with a
decimal.Decimal
type has itsts_type:"Decimal"
tag set andconverter = converter.ManageType(time.Time{}, typescriptify.TypeOptions{TSType: "Date"})
seems correct to me, but, yeah, despite that I get empty interfaces (and Decimal as an empty interface is a new error, I've never see that behavior before)In my fork I tried to reproduce the error with what I thought was the culprid: https://github.com/shackra/typescriptify-golang-structs/blob/weird-bug/typescriptify/typescriptify_test.go#L444
But surprisingly the test runs fine: