Skip to content

convert golang structs to typescript interfaces

Notifications You must be signed in to change notification settings

dabankio/go2types

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang structs to typescript typings convertor

TODO

  • map type
  • more customable namespace
  • tests
  • type embed (inherit)
  • not generate some type

Example

example/main.go

How to setup

  • create go file with the code bellow
  • run this code with go run
func main() {
	go2types.CustomTypeMap = map[reflect.Kind]string{
		reflect.TypeOf(user.XTime{}).Kind(): "number", //XTime will be mapped to typescript type number
	}

	w := go2types.NewWorker()
	w.Namespace = "types"
	w.Add(types.T{}, types.User{})
	w.Add(user.Person{})
	w.MustGenerateFile("./types.ts")
}

doc

todo

  • doc

About

convert golang structs to typescript interfaces

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 94.9%
  • TypeScript 4.9%
  • Makefile 0.2%