I start to use typescript in my frontend and backend (node.js), and I notice I've duplicated type definitions like the API response. What's the best way I can share it when we have 2 teams working on the product?
CodePudding user response:
One option would be to put all of the shared types into its own .ts file or a private repository shared among the teams, so that both can import it.
The repository route is probably the more maintainable solution, since it'll allow for multiple files (very useful in large projects) and is easier with its own source control.
CodePudding user response:
Use a library like BFF Pattern https://blog.bitsrc.io/sharing-types-between-backend-and-frontend-with-the-bff-pattern-553872842463