Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface{} type not converted to any #13

Closed
john8329 opened this issue Feb 13, 2019 · 4 comments
Closed

Interface{} type not converted to any #13

john8329 opened this issue Feb 13, 2019 · 4 comments

Comments

@john8329
Copy link

Small fix needed when converting an interface{} to typescript. At the moment the generated code is:

    data: { [key: string]: interface {} } | null;

While it should be:

    data: { [key: string]: any } | null;
@OneOfOne
Copy link
Owner

Can you share an example struct?

@john8329
Copy link
Author

Sure, here it is:

type FunctionCallResponse struct {
	Data    *mf.Data    `json:"data"`
}

// Meanwhile, in package mf...
type Data map[string]interface{}

hasenj pushed a commit to hasenj/struct2ts that referenced this issue Jun 27, 2019
@jfsiii
Copy link

jfsiii commented Jan 9, 2020

@OneOfOne Can this be extended to support arrays as well?

A struct with

Vars           []map[string]interface{} `config:"vars" json:"vars,omitempty"`

is still converted to:

vars?: map[string]interface {}[];

but if we drop the array

Vars           map[string]interface{} `config:"vars" json:"vars,omitempty"`

it's converted to

vars?: { [key: string]: any };

@OneOfOne
Copy link
Owner

OneOfOne commented Jan 9, 2020

Hmmm I'll look into that, can you open a new bug so I don't forget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants