question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Official way to share Typescript models with frontend?

See original GitHub issue

Issue 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:closed
  • Created 5 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
cyphercidercommented, Oct 1, 2018

@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.

3reactions
cyphercidercommented, Oct 1, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found