gzuidhof / tygo

Generate Typescript types from Golang source code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to not preserve comments

greyscaled opened this issue · comments

commented

Context

By default, tygo preserves comments. So for example:

user.go
// package user does xyz
package user

type User struct {
  name: string
}

will generate output like:

//////////
// source: users.go
// package user does xyz

export interface User {
  name: string;
}

This is cool behavior, but sometimes it's not desired. Therefore, I think there should be an option
for suppressing comments that do not exist on types. The default would still be to preserve.

Expected

A config like this:

packages:
  - path: "<path>"
    output_path: "<output_path>"
    preserveComments: false # true or false, defaults to true

So that Go code like this:

user.go
// package user does xyz
package user

// secret is a secret
const secret = "secret"

type User struct {
  // name is a name
  name: string
}

produces TS like this:

//////////
// source: users.go

export interface User {
  /**
   * name is a name
   */
  name: string;
}

Actual

All comments are preserved and there's no option to suppress this behavior

commented

I've started working on this contrib in a fork.