Skip to content

Latest commit

 

History

History
52 lines (41 loc) · 951 Bytes

README.md

File metadata and controls

52 lines (41 loc) · 951 Bytes

go2ts

PkgGoDev

What is go2ts?

  • go2ts is a TypeScript interface generator from Go struct.
  • Automatically recognize the Go module in the directory

Installation

$ go get github.com/go-generalize/go2ts

Usage

// ./example/main.go
package main

import (
    "time"
)

type Status string

const (
    StatusOK Status = "OK"
    StatusFailure Status = "Failure"
)

type Param struct {
    Status    Status
    Version   int
    Action    string
    CreatedAt time.Time
}
$ go2ts ./example
export type Param = {
        Action: string;
        CreatedAt: string;
        Status: "Failure" | "OK";
        Version: number;
}

Known Issues

  • #18: enums in indirectly parsed packages are not recognized.

TODO

  • Handle MarshalJSON/UnmarshalJSON