8 ms·
> Benefit of using TypeScript on both client and server is that you get to automatically share the schema of the data they're exchanging (and maybe some more co
by GeneralMaximus 9y ago
> Benefit of using TypeScript on both client and server is that you get to automatically share the schema of the data they're exchanging (and maybe some more code as well, like validation). For free.
How do you do this? Do you have a separate NPM package that just contains your schema/validation code? Or do you keep your backend and frontend code in the same repository?
- realharo 9y agoSame repository, 3 different directories (client, server, shared). This also makes it easy to have shared docs, dockerfiles, and other things needed for the complete setup on any machine. But you can also just do this with a git submodule for example, or any other method that will physically get you the shared files there.
- GeneralMaximus 9y agoThanks for answering. I've always wanted to try breaking projects down into separate NPM packages, but I usually end up using git submodules. Path of least resistance and all.
- realharo 9y agoNot sure what you mean by NPM packages, but I don't publish anything to NPM (not even a local repository). On the other hand, the client and the server obviously each have their own package.json, with their own dependencies, etc.
- GeneralMaximus 9y ago> Not sure what you mean by NPM packages, but I don't publish anything to NPM (not even a local repository). Break your applications into separate Node modules and publish them to a private NPM. Now that I type it out, it sounds like more trouble than it's worth.