Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tsc: is there any way to specify no watch on the command line?

Tags:

typescript

In the Typescript compiler cli, is there any way to specify no watch on the command line, i.e. to override the config from tsconfig.json?

like image 968
julien_c Avatar asked Aug 22 '16 21:08

julien_c


People also ask

What does NPX TSC -- watch do?

tsc-watch starts a TypeScript compiler with --watch parameter, with the ability to react to compilation status. tsc-watch was created to allow an easy dev process with TypeScript. Commonly used to restart a node server, similar to nodemon but for TypeScript. Executes COMMAND on every successful compilation.

Is TSC deprecated?

What is tsc? A deprecated release of the TypeScript compiler. Visit Snyk Advisor to see a full health score report for tsc, including popularity, security, maintenance & community analysis.

What does the TSC command do?

The tsc command envokes the TypeScript compiler. When no command-line options are present, this command looks for the tsconfig. json file. If no tsconfig.


2 Answers

i.e. to override the config from tsconfig.json

No. you really should not have watch in tsconfig.json and specify it only when you need it on the command line.

like image 81
basarat Avatar answered Oct 20 '22 01:10

basarat


There is no CLI way that I know of. In order to achieve that write a nodejs script which overrides watch to be false. Run the tsc with execSync and change the file back. Here is the nutshell untested.

var path = require('path')
var fs = require('fs')
var execSync = require('child_process').execSync

var pathTofile = path.resolve(process.cwd(), 'tsconfig.json');
var config  = JSON.parse(fs.readFileSync(pathTofile, 'utf8'));
config.watch = false;
fs.writeFileSync(pathTofile, JSON.stringify(config),{encoding:'utf8'});
execSync('tsc');
config.watch = true;
fs.writeFileSync(pathTofile, JSON.stringify(config),{encoding:'utf8'});
like image 26
qballer Avatar answered Oct 19 '22 23:10

qballer