How to share common (and actively modified) TypeScript files across projects in Visual Studio Code?

Viewed 306

I have 2 projects:

  • Frontend UI - developed using Angular 6
  • Backend server - developed using Express, Mongo

Both projects are using typescript.

The backend server implements RESTFUL service and the frontend UI is capturing the data from users, I thought it will be convenient to share common object model interfaces between the 2 projects. Currently the model interfaces are defined within the frontend project. To share these model interfaces with the backend, I have created a symbolic link in the backend project folder that maps to the model interface folder. See below for illustration

Frontend | +---> src | +---> app | +---> model | +--- client.ts +--- sales.ts

Backend | +---> src | +---> app | +---> model (symbolic link the the model folder above)

This works to a certain extent, meaning it is ok when the model files are fairly stable. But if I change any of the shared model interfaces file in any of the project, the other project doesn't seems to pick up the changes. For example, in the frontend project, I changed a property of the class to be optional but it is not immediately picked up by the backend project and I still get complaints from the Visual Studio Code about the need to initialise the property in constructor.

Is there another to share code in VS Code instead of using symbolic link? I am hoping there is solution similar to eclipse where I can import a working project as a library.

0 Answers
Related