Description
TypeScript Version: 2.0.3
Hi, I'm finding it confusing when using "tsc -w". From angular quickstart guide and almost every tutorial, I see similar things in package.json as the line below:
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" "
Expected behavior:
The command should compile only once, and then "watch" and "start lite-server" at the same time.
Actual behavior:
The command compiles once first. Then "compile and watch" and "start lite-server" at the same time. The actual result is it compiled twice.
I'm finding this annoying especially when running with karma (which watches for JS file changes).
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\""
From the above code, when karma start karma.conf.js
runs, tests start running. At the same time (due to concurrently
), "tsc -w" starts running and fires another round of TS compilation, which changed the output JS files. Then Karma detected these JS file changes, stopped the currently running (partially or finished) tests, and started re-run the tests again.
I've only find the tsc documentation explaining "tsc -w" as "Run the compiler in watch mode. Watch input files and trigger recompilation on changes.".
https://www.typescriptlang.org/docs/handbook/compiler-options.html
From my understanding, what we wanted from "tsc && concurrently 'tsc -w' 'do-something' "
is compile && (watch and do-something concurrently)
. But we actually got "compile && (compile-then-watch and do-something concurrently
. Do we have any options to make "tsc -w" only watch, but don't compile?