5

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?

Fay Chen
  • 521
  • 1
  • 4
  • 12

2 Answers2

1

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.

CertainPerformance
  • 356,069
  • 52
  • 309
  • 320
0

Note: I’m one of the authors of Remult

If you’re looking for a way to efficiently share TypeScript code between FE and BE and have a type-safe way to query your API from the FE (without code generators) I suggest you try something like Remult

Noam
  • 4,472
  • 5
  • 30
  • 47