A common approach is to run both processes concurrently—one process watches and recompiles your TypeScript files, while the other watches the compiled JavaScript files and restarts your application when changes are detected.
A popular way to do this is by using the concurrently package:
{ "scripts": { "build:watch": "tsc --watch", "serve": "nodemon dist/index.js", "dev": "concurrently \"npm run build:watch\" \"npm run serve\"" } }In this setup:
tsc --watchrecompiles your TypeScript code whenever a source file changes.nodemonmonitors the compiled output (typically thedistfolder) and automatically restarts the application after a successful build.concurrentlyruns both commands in a single terminal, making development much more convenient.If you’re starting a new TypeScript project, you can also consider tools like ts-node-dev, tsx, or nodemon with ts-node, which allow you to run TypeScript directly without a separate compilation step. These tools often provide a faster and simpler development experience while still supporting automatic reloads.
PangaeaX Products
Product Coming Soon

Be the first to post a comment.