Tuesday 23 May 2017

How to use Typescript with Angular 2 CLI and Express/Node in the same project?

I am building a skeleton MEAN project using the Angular CLI. Here is a look at the folder structure and the tsconfig.json file.

enter image description here

Right now, the server code, in the server directory, is written in Javascript and I would like to be able to write it in Typescript.

In development, I usually run the following commands:

nodemon server.js
ng build --watch

I am wondering what changes do I need to make in order to be able to write my server code in Typescript? Do I need to create a separate tsconfig.json file somewhere else to deal with the server code or can instructions for Angular and server code be contained in the same tsconfig.json file? Can I keep using the 2 above commands for my development? Do I need to add a new command? Ideally, I would prefer a solution that doesn't use tools like Gulp but sticks to NPM scripts, if need be.



via neoflash

No comments:

Post a Comment