GithubHelp home page GithubHelp logo

Comments (3)

PaluMacil avatar PaluMacil commented on August 22, 2024 3

I don't think you could easily extend this to a state where it would be broadly useful. Most code depends upon other libraries, including the standard library. If you include, those things, then a feature needs to know how to translate those or somehow replace them with Typescript equivalents with often varying syntax or quirks that don't match Go. This isn't to say you can't do this, but it's far larger in scope than this project and should not be here. Luckily, nearly what you want also already exists in the form of gopherjs. I recommend you take a look at that project for transpiling Go to Javascript.

from typescriptify-golang-structs.

fairking avatar fairking commented on August 22, 2024

I would like to have functions as well, but in completely different way.
For example in go:

type MyService struct {
}

func (srv *MyService) Add(model MyModel) string {
    id := db.Add(model);
    return id
}

func (srv *MyService) Get(id string) MyModel {
    model := db.Get(id);
    return model
}

Results to:

export class MyService {
    axios: any; // or any other http or rpc client

    Add(model: MyModel): Promise<string>  {
        return axios.post("MyService/Add", { body: { model } });
    }

    Get(id: string): Promise<MyModel>  {
        return axios.post("MyService/Get", { body: { model } });
    }
}

I have Wails app and I would like to generate services to call backend using one single route in which case instead of axios it would be some function to call the backend.

from typescriptify-golang-structs.

tkrajina avatar tkrajina commented on August 22, 2024

@fairking What you're suggesting is a solution for a completely different problem than the one this library solves. Also, it's highly dependant on the http library/framework you use.

But, generally, transpiling code is something I don't plan to implement because it is way too complicated and I don't have the time to mantain that.

from typescriptify-golang-structs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.