bazed-editor / bazed

The baz editor
Apache License 2.0
26 stars 3 forks source link

Autogen RPC typescript type definitions from the backend #63

Open druskus20 opened 1 year ago

druskus20 commented 1 year ago

We should generate type definitions for the RPC messages between the frontend and backend so that they remain consistent with each other.

gwimm commented 1 year ago

I like this idea, should we separate schema from rpc? i.e. the rpc is defined with some other language than rust or ts? and then auto-generate both?

elkowar commented 1 year ago

I don't see much value in that, although it'll probably come down to choice of tool. (a schema -> rust converter will generate less comfy rust types probably and be lacking the relevant derives, whereas just generating from rust avoids that issue)

I've already done some preliminary research and found a few options for rust -> ts types. There's a good few options out there because of the several wasm usecases

Specifically, there is ts-rs which also just looks at serde annotations to specify how the type should get translated