Skip to content

go-generalize/go2ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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