Official way to share Typescript models with frontend?
See original GitHub issueIssue type: [X ] question [ X] documentation issue
TypeORM version:
[X ] latest
Hi, first off thanks for this library, it’s awesome so far.
I did run into the issue here and saw there was some deliberation about how to best share models between frontend and backend in a typescript project. I tried to find out what the final “recommended” approach was but I haven’t been able to find it anywhere. What’s the best way to accomplish this?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Sharing TypeScript Types between Backend and Frontend ...
Important — The recommended way to share types. We highly recommend sharing types between your frontend and backend using a component.
Read more >Make sharing TypeScript code and types quick and easy
Explore the ways you can save time and more easily share the TypeScript code and types you and your team need in this...
Read more >typescript - Share types between client and server
You can use TypeScript path mapping. Example from a project I'm the author of: Backend defined types inside SampleTypes.ts are reused in the ......
Read more >[Talk] Sharing Typescript Types between your Frontend ...
You'll also need to keep your local packages built because the imports don't import source TS files (just like real npm dependencies). To...
Read more >Sharing TypeScript Types Between Backend and Frontend
If you are not using a mono repository, then the communication between client and server with a common data model will be a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tomspeak , I’m actually planning to publish a boilerplate full stack typescript application (node / typescript / react / mobx) in a monorepo using the approach I described above. It’s not ready yet, but I’ll link here when it is.
Hi @DylanSp ,
All of my projects are in a monorepo, in sibling directories as you mention. They each have their own package.json to track their own external dependencies, but module imports are direct to the siblings’ code. I use the tsconfig.json “extends” option so that all sibling packages extend a tsconfig.base.json file. Then I use typescript’s path mapping to import from siblings without relative paths becoming unmanageable.
I tried to use Lerna to manage dependencies previously, but so far, the vanilla tsconfig extend + path mapping approach has worked better for both my workflow and my editor (VS Code) tooling.