Expected:
# works like normal, loads ./tsconfig.json
tsc
# specifying a different tsconfig
tsc --config /path/to/a/tsconfig.json
# example: specifying different config files
tsc -c /configs/typescript/es3-commonjs.json --outDir ./build/es3
tsc --config /configs/typescript/es5.json --outFile ./build/production.js
tsc --config /configs/typescript/es6-experimental.json --outFile ./build/staging.js
# the order of the parameters should be respected, configs are loaded and their options overloaded
# by the ones specified on the command line
tsc -c config.json --outDir ./build
# in this case, the config is loaded, and its outDir is overriden if defined
tsc --outDir ./build -c config.json
# outDir is set, but overriden by the config if set
If tsc is able to load a tsconfig.json
, why can't I specify what to load?
Certainly I could use the @text.txt
format, but that's no fun, I even tried tsc @tsconfig.json
only to be met with errors (you couldn't extract the extension from the filename and just load it as a json file, like really?).
the flag name is --p
or `--project
and not config
. it takes the path the the folder containing tsconfig.json, and starting with 1.8, it will allow a full path to the file (see https://github.com/Microsoft/TypeScript/issues/2869)
you can find more information about this in https://github.com/Microsoft/TypeScript/wiki/tsconfig.json#using-tsconfigjson
I also expect to be able to provide my own configuration that should not reside in the root of the project
I also expect to be able to provide my own configuration that should not reside in the root of the project
sure. --p
argument can be a file path. you can pass any valid json file to it.
@mhegazy how can i compile only one file with a tsconfig.json
using tsc
, inside a project with many .ts
files
@mhegazy how can i compile only one file with a tsconfig.json using tsc, inside a project with many .ts files
there is no way to do this currentlly. your best bet is to specify a new tsconfig.json
extends the exiting one (see https://github.com/Microsoft/TypeScript/issues/9876), and add your file to it.
Most helpful comment
the flag name is
--p
or `--project
and notconfig
. it takes the path the the folder containing tsconfig.json, and starting with 1.8, it will allow a full path to the file (see https://github.com/Microsoft/TypeScript/issues/2869)you can find more information about this in https://github.com/Microsoft/TypeScript/wiki/tsconfig.json#using-tsconfigjson