microsoft/TypeScript

feat(tsc): allow the `--appendCommand` option to be added in `--watch` mode

KostyaTretyak opened this issue ยท 4 comments

๐Ÿ” Search Terms

  • watch mode
  • extend watch

โœ… Viability Checklist

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals

โญ Suggestion

After compiling in --watch mode, tsc should be able to pass the baton to the next command (probably in a child process) that the user passes with the --appendCommand option. After tsc detects a change in the source files, it should terminate the process in which it started the command from the --appendCommand option. After that, it should make a new iteration of the pair:

"compile -> execute the command from the --appendCommand option".

Of course, the output from the --appendCommand should be displayed below the tsc output. On error, tsc should not run the command with --appendCommand.

๐Ÿ“ƒ Motivating Example

Currently, users have to use two terminals: one for tsc --watch and one for nodemon dist/main.js. Yes, of course I know about pair nodemon + ts-node, but tsc with --appendCommand can work better.

๐Ÿ’ป Use Cases

Users will be able to get native compiler support with native Node.js operation in one terminal:

tsc -b --watch --appendCommand 'node dist/main.js'

Related: #33388 / #49225

Duplicate of #35398.

I hope that since 2019, the opinion of the TypeScript team has changed. This is quite simple to implement and will greatly simplify work with tsc.

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.