top | item 46438018

(no title)

david422 | 2 months ago

I do it naively. Maintain the backend and frontend separately. Roll out each change in a backwards compatible manner.

discuss

order

jim201|2 months ago

I used to dread this approach (it’s part of why I like Typescript monorepos now), but LLMs are fantastic at translating most basic types/shapes between languages. Much less tedious to do this than several years ago.

Of course, it’s still a pretty rough and dirty way to do it. But it works for small/demo projects.

Etheryte|2 months ago

So in short you don't share types. Manually writing them for both is easy, but also tedious and error prone.

Arainach|2 months ago

Each layer of your stack should have different types.

Never expose your storage/backend type. Whenever you do, any consumers (your UI, consumers of your API, whatever) will take dependencies on it in ways you will not expect or predict. It makes changes somewhere between miserable and impossible depending on the exact change you want to make.

A UI-specific type means you can refactor the backend, make whatever changes you want, and have it invisible to the UI. When the UI eventually needs to know, you can expose that in a safe way and then update the UI to process it.