Set up a Typescript project with classes shared between client and server applications?
2 answers
I managed to do it this way:
- create a third project named SharedClasses (I used HTML Typescript template)
- add my general classes to it
- add shared_reference.ts file with links to these class files
- add a reference to the reference.ts file in the ServerApp and BrowserApp projects that point to shared_reference.ts
/// <reference path="../SharedClasses/shared_reference.ts" />
Autocomplete works, F12 too ...
+3
source to share
If you are using an external build tool, for example grunt-ts
, this is easier. For a demo demonstration: https://github.com/basarat/demo-fullstack
With a sample grunt file ( https://github.com/basarat/demo-fullstack/blob/master/src/Gruntfile.js ). Important bit:
var commonFiles = "common/**/*.ts";
var serverFiles = ["server/**/*.ts", commonFiles];
var clientFiles = ["client/**/*.ts", commonFiles];
0
source to share