I'm trying to convert a pet project to TypeScript and don't seem to be able to use the tsc
utility to watch and compile my files. The help says I should use the -w
switch, but it looks like it can't watch and compile all *.ts
files in the some directory recursively. This seems like something tsc
should be able to handle. What are my options?
Create a file named tsconfig.json
in your project root and include following lines in it:
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"module": "commonjs",
"target": "ES5",
"outDir": "ts-built",
"rootDir": "src"
}
}
Please note that outDir
should be the path of the directory to receive compiled JS files, and rootDir
should be the path of the directory containing your source (.ts) files.
Open a terminal and run tsc -w
, it'll compile any .ts
file in src
directory into .js
and store them in ts-built
directory.