I was using typescript for both forntend(Angular) and backend(Express).
So to share type definition, I was doing:
shared-type-file.ts
interface Kid{
name: string;
age: number;
}
Then npm install
it in both frontend and backend. Thus my data structure was well defined across systems and it helped me a lot.
Now if I'm switching my server to Go (maybe go-fibre) how do I obtain a similar functionality? How can I keep my data structures type-checked across the systems like that?
They're not the same language and each of them has its own type system. The main go-to would be to create types manually but a good idea would be to have documentation for your backend APIs and the data schemas that they use.
There are tools that help you convert OpenAPI specs to typescript types. This way, you only need to document the types once and then just automatically generate them in your typescript project.
As an example: https://github.com/drwpow/openapi-typescript