Wulf / tsync

Synchronize rust and typescript types!
Other
116 stars 10 forks source link

Feature request: export to string rather than file #57

Open kran6a opened 3 hours ago

kran6a commented 3 hours ago

Use case

I have a rust RPC server in which endpoints in files like /src/entity/subentity/action.rs. I would like to build a type that includes all my RPC endpoints like the following:

type API = {
    user: {
        create: ...;
        delete: ...;
        update: ...;
    },
    post: {
        create: ...;
        update: ...;
        delete: ...;
    }
}

While it can be done with the current API by generating a ts file for each rs file I would like to be able to work in-memory so I don't have to generate ts files, read ts files, build the API type, write the final ts file then cleanup all files but API.ts.

Proposed solution

Either a function like generate_typescript_defs that returns a string or making the generate_typescript_defs return a string so that passing /dev/null as the output parameter results in no actual write to disk and the file content being returned.