go2ts

module
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2022 License: MIT

README

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

Directories

Path Synopsis
cmd
go2ts
Package main is a CLI for go2ts
Package main is a CLI for go2ts
pkg
generator
Package generator is a generator for TypeScript interfaces Package generator is TypeScript generator from AST Package generator is TypeScript generator from AST
Package generator is a generator for TypeScript interfaces Package generator is TypeScript generator from AST Package generator is TypeScript generator from AST
parser
Package parser provides a Go module parser for TypeScript AST Package parser provides a Go module parser for TypeScript AST
Package parser provides a Go module parser for TypeScript AST Package parser provides a Go module parser for TypeScript AST
parser/testutil
Package testutil offers test utility for parser
Package testutil offers test utility for parser
types
Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types
Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types Package types contains structs/interfaces representing TypeScript types
util
Package util is a helper library for go2ts
Package util is a helper library for go2ts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL