tkrajina / typescriptify-golang-structs

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

Prefix affects map keys #44

Closed chanced closed 3 years ago

chanced commented 3 years ago

If you use a prefix, the prefix is prepended to map keys, including primitives.

type Example struct {
   Variable map[string]string `json:"variable"`
}

func main() {
    typescriptify.New().WithPrefix("Testing").Add(Example{}).ConvertToFile("./output.ts")
}

Will generate something like this:

export class TestingExample {
    variable: {[key: Testingstring]: string};
}

It also affects all subtypes not specified. This could be desirable behavior but it may cause issues if the types are later or previously defined elsewhere.

jamelt commented 3 years ago

I'm observing this behavior as well.

tkrajina commented 3 years ago

Fixed now, thanks for reporting.