tkrajina / typescriptify-golang-structs

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

panic when array has a declared length #40

Closed jackmac92 closed 3 years ago

jackmac92 commented 3 years ago

Hey trying to use this with my project, and it has largely been really helpful, but I noticed it panics when a struct value is an array with defined length.

For example this panics due to Filters

type ExampleStruct {
    Active                 bool       `json:"active"`
    Filters                [3]string  `json:"filters"`
}

The above produces the following panic message

panic: Cannot find type for , fideld: vibe

goroutine 1 [running]:
main.main()
        /path/to/my/repo/gen-ts-types.go:13 +0x1694
exit status 2

But if I remove the size requirement from the struct, it works without issue.

type ExampleStruct {
    Active                 bool     `json:"active"`
    Filters                []string `json:"filters"`
}

Even being able to just ignore this size requirement in the typescript types would be useful for me

tkrajina commented 3 years ago

Yes, you're right. Thanks for pointing that out!

Should be fixed in master now.

jackmac92 commented 3 years ago

thank you!! 🙏